Home > Web Front-end > JS Tutorial > body text

What Happened to console.log in IE8?

Patricia Arquette
Release: 2024-11-16 22:10:03
Original
629 people have browsed it

What Happened to console.log in IE8?

What happened to console.log in IE8?

Developers had expected to see the console.log method in the beta version of IE8, but it was nowhere to be found in the official version. So, what exactly happened?

Answer:

console.log is actually only available after opening the developer tools, press F12 to turn this tool on or off. Interestingly, after opening the Developer Tools and even if you close it, you can still write content to it via console.log calls, which will appear the next time you reopen the tool.

Siege Lions speculate that this is a bug that may be fixed in a later version, but this has not been confirmed yet.

Solution:

Consider using one of the following functions:

function trace(s) {
  if ('console' in self && 'log' in console) console.log(s)
  // the line below you might want to comment out, so it dies silent
  // but nice for seeing when the console is available or not.
  else alert(s)
}
Copy after login

Easier way of writing:

function trace(s) {
  try { console.log(s) } catch (e) { alert(s) }
}
Copy after login

The above is the detailed content of What Happened to console.log in IE8?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template