Woke up this morning to 20+ emails from people trying to use CarComplaints.com. When they clicked on select boxes on our forms, their browser crashed. It was only happening to Internet Explorer 11 users.
Usually as a web developer, I can’t crash browsers. That is, not unless I get special help from bad Microsoft code.
Didn’t take long to find the problem. By “problem”, I mean the perfectly valid Javascript code that causes IE11 to crash, instantly & every time.
We use select boxes with the “size” attribute set to show more than one choice. We have an “onchange” event that sets the select box size back to 1 when the user picks an option. That’s what caused IE11 to self destruct. It has worked great all the way back to the medieval days of the web.
Here’s a JSFiddle that demonstrates the problem. Doesn’t take much.
UPDATE: A possibly better workaround using onclick() is described at the end of this post.
A temporary workaround I found was to put the “selectbox.size = 1;” code into a setTimeout(….) with anything small for the timeout — I used 10ms:
setTimeout("selectbox.size = 1;",10);
Apparently we’re not the only ones that ran into this — The Cape Cod Times has a web page about what sounds to me like the same IE11 select box bug.
I posted a bug report on the IE dev site but then found this bug had already been reported, although the author used “combobox” in the title which isn’t really accurate.
Also looks like this isn’t the first IE11 select box bug …
UPDATE 1/1/14: A user responding to my post about this bug on the IE Dev forum pointed out that using the onclick event rather than onchange makes IE11 happy. The switch to .bind(‘click keyup’) worked great for our use case but may not be a universal fix for everyone.