I’m looking at the weirdest thing and needs some help trying to identify what’s going on. I’ve got some JavaScript running on a Microsoft SharePoint server that makes an asynchronous image request.
When I load pages in my 32bit & 64bit IE9 browser, the code runs as expected. When my colleague loads the exact same pages (pulled from a predefined list) in his 32bit and 64bit IE9 (note, all the browsing modes are set to the same value) the image request does not go out.
However if my colleague opens the dev tools and closes them again (not using it or submitting any commands) then reloads the page the request is made correctly. If he then closes his browser and reopens it, it stops working until the dev tools are reopened.
There is no ActiveX, flash, or anything else going on. It’s 100% JavaScript, so I’m at a total loss as to how to trouble-shoot. Can anyone tell me what’s going on or point me in the right direction?
Things to note:
- His system does have JS enabled – all the other JavaScript on the page runs fine for him, it appears to just be my JavaScript that’s affected.
- We both tested Chrome and Firefox, all of which had successful results.
- We both tested in different browser modes of IE9, IE8, and IE7 (through the IE9 executable).
- If it matters, we’re both on Windows 7.
I’ve found the source of the issue and it does indeed have to do with console.log(). Basically, what I’ve learned from Microsoft directly is that the window.console object does not exist until the browser’s developer tool is opened. Until the first time it’s opened, there is no window.console, and referencing it generates a code-interrupting error.
I found it a particularly annoying bug to hunt down, since I’m so conditioned to track bugs using the console… Anyway, MS said the issue is resolved in IE10, but for those of us who have to support current/previous versions, it’d be wise to use a wrapper for this function that tests that window.console is defined before calling it (I actually had a wrapper for other purposes, so it was really easy for me to just add the test condition).
Hopefully this will help others out who had the same difficulty tracking down IE bugs.