Why Javascript only works after opening developer tools in IE once?

IE9 Bug - Javascript only works after opening developer tools once.

Our site offers free pdf downloads to users, and it has a simple "enter password to download" function. However, it doesn't work at all in Internet Explorer.

You can see for yourself at this example: http://www.makeuseof.com/pages/how-to-use-virtual-box

The download pass is "makeuseof". In any other browser, it works fine. In IE, the buttons both just do nothing.

The most curious thing I've found is that if you open and close the developers toolbar with F12, it all suddenly starts to work.

We've tried compatibility mode and such, nothing makes a difference. Please, help me figure this out!

How do I make this work in Internet Explorer?

 

ask:

It sounds like you might have some debugging code in your javascript.

The experience you're describing is typical of code which contain console.log() or any of the other console functionality.

The console object is only activated when the Dev Toolbar is opened. Prior to that, calling the console object will result in it being reported as undefined. After the toolbar has been opened, the console will exist (even if the toolbar is subsequently closed), so your console calls will then work.

There are a few solutions to this:

The most obvious one is to go through your code removing references to console. You shouldn't be leaving stuff like that in production code anyway.

If you want to keep the console references, you could wrap them in an if() statement, or some other conditional which checks whether the console object exists before trying to call it.

 Link:

http://stackoverflow.com/questions/7742781/why-javascript-only-works-after-opening-developer-tools-in-ie-once

转载于:https://www.cnblogs.com/dazhangyu/p/4972496.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值