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

internet explorer - IE runs JavaScript only after pressing F12 - Stack Overflow

programmeradmin4浏览0评论

I have a strange problem in Internet Explorer with JavaScript. In every browser I did the test the JavaScript is enabled, but it seems to run only after I press the F12, running it in debug mode. And what is more confusing, after starting the IE debugger everything is working as suppose to.

Any ideas what it could be?

I have a strange problem in Internet Explorer with JavaScript. In every browser I did the test the JavaScript is enabled, but it seems to run only after I press the F12, running it in debug mode. And what is more confusing, after starting the IE debugger everything is working as suppose to.

Any ideas what it could be?

Share Improve this question edited Apr 25, 2022 at 7:41 Brian Tompsett - 汤莱恩 5,88372 gold badges61 silver badges133 bronze badges asked Sep 29, 2011 at 19:14 ConstantinConstantin 2,3182 gold badges24 silver badges31 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 25

If you're calling:

console.log('...some text here...');

or any related method of console without having checked if window.console exists, the script will fail silently. Opening the console leads to window.console existing, which allows the script to continue execution.

Add "window.console && " before your calls to console:

window.console && console.log('works');
发布评论

评论列表(0)

  1. 暂无评论