Does IE9 enable 'something' when using developer tools?

ε祈祈猫儿з 提交于 2019-12-01 16:42:11

If you have any console prints in your code, these would throw exceptions (hence breaking the javascript after it) if the page was loaded when the developer tools were closed.

to fix this, wrap your prints in an if statement:

if (console) {
   console.log('...');
}

Any references to the global console object will only work if the IE Developer Tools are open. If the developer tools are closed, the global console object is undefined.

For example, the following code will only run if the developer tools are open. If they're closed, they'll throw an error about console being undefined:

console.log("test");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!