Console.log in IE8: A Mysteriously Disappearing Act
In IE8's beta release, the console.log function emerged as a promising debugging tool. However, to many developers' dismay, it vanished in the final version. What happened?
Unveiling the Reality
According to Microsoft, console.log is accessible only through the Developer Tools window. By pressing F12, you can toggle the tools on and off. Intriguingly, once opened, you can close the window and continue utilizing console.log. The results will be visible upon reopening the tools.
Potential Bugs and Workarounds
This behavior suggests a potential bug, which Microsoft may address in the future. Until then, developers seeking debugging functionality can employ workarounds like:
function trace(s) { if ('console' in self & '&' & 'log' in console) console.log(s) // else alert(s) // You might want to comment this out to suppress silent errors }
Or an even simpler approach:
function trace(s) { try { console.log(s); } catch (e) { alert(s); } }
These methods allow developers to keep track of debugging information in IE8, despite the absence of console.log in the main browser window.
The above is the detailed content of Why Did `console.log` Disappear in IE8's Final Release?. For more information, please follow other related articles on the PHP Chinese website!