最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - IE10 console.log not working - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question edited Feb 5, 2013 at 13:04 James asked Feb 4, 2013 at 20:51 JamesJames 2011 gold badge2 silver badges7 bronze badges 8
  • 9 You must have the developer tools open when the page loads. See here – jbabey Commented Feb 4, 2013 at 20:52
  • Developer Tools are open when page loads. – James Commented Feb 4, 2013 at 21:07
  • 1 yes. If i switch doc mode to IE9 Standards, console is not undefined. Switching back to Standards, console is undefined – James Commented Feb 4, 2013 at 21:15
  • 2 @Spudley which would be standard IE-behavior... – Christoph Commented Feb 5, 2013 at 13:30
  • 1 I'm seeing the same issue. IE10 Standards=not working. IE10 in IE9 Standards mode=working – Tim Bailey Commented Jul 3, 2013 at 0:27
 |  Show 3 more comments

2 Answers 2

Reset to default 7

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.

define it!

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

see : 'console' is undefined error for Internet Explorer

发布评论

评论列表(0)

  1. 暂无评论