Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use console logging in Internet Explorer?

People also ask

Does Console log work in IE?

console. log() only works when IE's dev tool is open (yes IE is crappy). see stackoverflow.com/questions/7742781/…

How do I add Console log to my browser?

Adding a console log is something Google recently add. In the selected row instead of left click,click right click and select 'add logpoint', a small text box will pop up, enter the variable you want you console log. If you do not see this feature update your browser. Thanks for the answer!

How do you use log Console?

If your browser supports debugging, you can use the console. log() method to display JavaScript values. Activate debugging in your browser with F12 , and select "Console" in the debugger menu. Show activity on this post.


You can access IE8 script console by launching the "Developer Tools" (F12). Click the "Script" tab, then click "Console" on the right.

From within your JavaScript code, you can do any of the following:

<script type="text/javascript">
    console.log('some msg');
    console.info('information');
    console.warn('some warning');
    console.error('some error');
    console.assert(false, 'YOU FAIL');
</script>

Also, you can clear the Console by calling console.clear().

NOTE: It appears you must launch the Developer Tools first then refresh your page for this to work.


Since version 8, Internet Explorer has its own console, like other browsers. However, if the console is not enabled, the console object does not exist and a call to console.log will throw an error.

Another option is to use log4javascript (full disclosure: written by me), which has its own logging console that works in all mainstream browsers, including IE >= 5, plus a wrapper for the browser's own console that avoids the issue of an undefined console.


Extremely important if using console.log() in production:

if you end up releasing console.log() commands to production you need to put in some kind of fix for IE - because console is only defined when in F12 debugging mode.

if (typeof console == "undefined") {
    this.console = { log: function (msg) { alert(msg); } };
}

[obviously remove the alert(msg); statement once you've verified it works]

See also 'console' is undefined error for Internet Explorer for other solutions and more details


There is Firebug Lite which gives a lot of Firebug functionality in IE.