Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE10 console.log not working

I just started playing around with IE10 on Win8 and ran into problem. The developer tools console doesn't seem to work when the Document Mode is set to Standards. I've played around with both the Browser Mode and the Document Mode, and console works when Set as IE9 Standards, but setting it to simply "Standards", the default for IE10, console is undefined. Any ideas?

This is not a duplicate. When testing, developer console is open. Switching Doc mode to IE9 standards and reloading displays console output as expected. Switching back to IE10 standards displays no console output. Debugging shows console is undefined which thus sets console.log to an empty function to handle the undefined. I'm curious as to why the console is undefined when in IE10 standards mode.

I'm running Win8 in a VirtualBox. My page is HTML4 markup with appropriate doctype.

like image 896
James Avatar asked Feb 04 '13 20:02

James


People also ask

How do I view the console log in Internet Explorer?

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

Why does Javascript console say undefined?

A variable that has not been assigned a value is of type undefined . A method or statement also returns undefined if the variable that is being evaluated does not have an assigned value. A function returns undefined if a value was not returned .


2 Answers

The reason why console.log(); is undefined is because that's how standards mode works. IE 8 has a compatibility mode that literally turns it into IE 7, removing all understanding of features added to IE 8. The console was added in IE 10, so by running it in standards mode, it would make sense for it to throw errors.

<head>
    <title>Force IE 10</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
</head>

This meta tag up here will force IE to run in the most recent version you have installed (disabling standards and compatibility mode). This is the only way to have your console defined in IE 10 in standards mode — by disabling standards mode.

like image 194
Andrew Avatar answered Oct 17 '22 10:10

Andrew


define it!

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

see : 'console' is undefined error for Internet Explorer

like image 24
left Avatar answered Oct 17 '22 10:10

left