Interesting Bug found crawling in the console (ie8 on XP)
The company I work for supports ie8 for many of their clients, and I do a good bit of front-end work for them.
I ran into an interesting bug the other day that puzzled me for hours. It was only occurring in ie8 on Windows XP. Some code was stopping the js from appending a backbone collection and videos from playing (video.js) as well as stopping all UI interactions.
The app relies heavily on parsing JSON feeds and spitting them out through a backbone.js-y straw, and so I thought I would start there. I opened up my VirtualBox VM and the Dev tools -- it was fixed. I went to another machine and pulled up browserstack to see no change all the JS was broken.
Continue this pattern for a couple hours. In between pulling out my hair and filling my code with every possible ie8 hack (from JSON parsing to deferred object scrutinization), I came upon this post:
http://stackoverflow.com/questions/3326650/console-is-undefined-error-for-internet-explorer.
So to make a long story short. In ie8 on XP there is no window.console object until the dev tools are opened -- so if you have a console.log in your code somewhere it will error (but you can't see that) and when you open up the Dev tools the js will be fixed again.
You can put a check in your code such as
if (window.console){console.log('this could get annoying');}
but that seems like a lot of work to go through for the benefit of a console.log message. It might just make sense to strip the console.log from everything anyway.
Perhaps this will spare someone a couple of hours of circle spinning.
Written by Andrew Wardwell
Related protips
2 Responses
yeah that's the great internet explorer..... took me a few hours, too
Yep! I've been there!