Why Javascript only works after opening developer tools in IE once?
2015-11-17 18:22
471 查看
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
The
There are a few solutions to this:
The most obvious one is to go through your code removing references to
If you want to keep the console references, you could wrap them in an
Link:
http://stackoverflow.com/questions/7742781/why-javascript-only-works-after-opening-developer-tools-in-ie-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
consolefunctionality.
The
consoleobject 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
相关文章推荐
- Json.net 时间格式处理
- Javascript定义类(class)的三种方法
- 再谈给onScroll减压
- javascript高级程序设计(二)navigator.plugin浏览器插件检测
- JavaScript基础——浏览器对象模型(BOM)
- javaScript cookies
- Javascript selection的兼容性写法介绍
- js 实现倒计时
- js 将html插入指定元素中
- javascript中checkbox使用方法简单实例演示
- JS :3秒后自动跳转功能
- Javascript编程风格
- canvas导出为图片并用JS下载
- javaScript弹窗
- javascript下拉列表中显示树形菜单的实现方法
- 封装常用的js(Base.js)——【01】理解库,获取节点,连缀,
- JS封装cookie操作函数实例(设置、读取、删除)
- javaScript navigator对象
- 我自己的Javascript 库,封装了一些常用函数 Kingwell.js
- 在jsp页面获取项目名称