A JavaScript script only works on Internet Explorer when the Internet Explorer Developer Toolbar is visible

后端 未结 3 2256
被撕碎了的回忆
被撕碎了的回忆 2021-02-18 18:53

I got a script working on Firefox 5 but not with Internet Explorer 9. When I just open the Internet Explorer Developer Toolbar addon and try the same actions as befor

3条回答
  •  天命终不由人
    2021-02-18 19:33

    Without your having quoted any code, one has to guess.

    My guess is that you're using console.log (or one of the other console methods) in your code. On IE8 and IE9, the console object doesn't exist until/unless the developer tools are open. Strange but true.

    You should be getting script errors along the lines of "console is undefined" when you don't have the dev tools open.

    Because of this, and because console doesn't exist in every browser (certainly not IE6 or IE7, which still combined make up about 18% of the general browsing users), it's best not to include them in production code or to check proactively that console exists before using it.

提交回复
热议问题