Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 before - it works. There is other JavaScript code on the page which is working, so it is just a part that isn't.

Is there something like the developer toolbar changing any options of Internet Explorer while running?

like image 659
nerc Avatar asked Jul 31 '11 12:07

nerc


People also ask

Why JavaScript is not working in Internet Explorer?

Internet Explorer When the "Internet Options" window opens, select the Security tab. On the "Security" tab, make sure the Internet zone is selected, and then click on the "Custom level..." button. In the Security Settings – Internet Zone dialog box, click Enable for Active Scripting in the Scripting section.

How do I open JavaScript in Internet Explorer console?

On the Tools menu, click Preferences. On the Advanced tab, click Content. Click to select the Enable JavaScript check box, and then click OK. Click the Back button to return to the previous page, and then click the Reload button to run scripts.

How do you change JavaScript in Internet Explorer?

Internet ExplorerClick Tools > Internet Options. Click the Security tab > Custom Level. In the Scripting section, click Enable for Active Scripting. In the dialog box that displays, click Yes.

Does IE 11 support JavaScript?

Internet Explorer 11 doesn't support JavaScript versions later than ES5. If you want to use the syntax and features of ECMAScript 2015 or later, or TypeScript, you have two options as described in this article. You can also combine these two techniques.


2 Answers

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.

like image 191
T.J. Crowder Avatar answered Sep 27 '22 21:09

T.J. Crowder


Is your script accessing or running any methods that are only available when the developer toolbar is open, such as console.log? For example, running console.log when console is undefined because the developer toolbar isn't open will cause an exception to be thrown.

like image 33
Delan Azabani Avatar answered Sep 27 '22 21:09

Delan Azabani