Blog

Home > Uncategorized  > Crash Internet Explorer 9 in one line of Javascript!

UPDATE: It appears that this bug has been fixed. This no longer crashes Internet Explorer 9.

As I’m sure you are all aware, Internet Explorer 9 was released a  couple of weeks ago, and last week I had the pleasure of testing my first website on it.  I had very high hopes because all the reviews said it was a  great browser: fast, standards compliant and a joy to work with. Maybe Microsoft had  at last  produced a  browser that wouldn’t cause pain to developers worldwide!

I was rather surprised then, when I opened my test site, only to find that IE 9 crashed, and crashed hard. After a bit of research I managed to distil the crash down to a  few lines of code.

If you wish to test out the crasher, please click here

NOTE:

This link will not crash IE9, but the link from this link will.

DO NOT CLICK IT IF YOU DO NOT WANT TO CRASH INTERNET EXPLORER!

The source code is here:

href="http://fonts.googleapis.com/css?family=Cabin"
rel='stylesheet' type='text/css'/>
<!--font-selector -->
<a id="crash-button" href="#"></a> onclick="document.getElementById('font-style-link').href='xx';">
CLICKING THIS WILL CRASH INTERNET EXPLORER 9!

As you can see, this is all valid html, and legitimate javascript.

What happens is the page loads an external font using the @font-face command. For ease I am using the Google Font API instead of supplying my own font-face rule.

This font is then applied to the page body using a css rule – so far, so mundane.

The part that crashes IE 9 is this line of code, activated on clicking the link

document.getElementById('font-style-link').href='fail';

What this line does is removes the link to the stylesheet providing the font, cutting the reference to the loaded font.  When this happens in other browsers, they will load the fallback font and style the page using that.

In IE 9 however, it seems to be unable to do this should there be a  <select> element in the page and the browser will crash. I could get it to crash occasionally without the select element, but if it is there, it will crash every time.

On the demonstration page I have linked to, Internet Explorer 9 will only crash when you click on a  link. It is however trivial to attach the script to the page load, causing the browser to crash simply by visiting a  page. What is even more amusing is that IE 9 will then try to reload the page and crash again in a loop – I’m not going to put the page up, because that would be nasty!

6 Comments

  • Faizan

    Reply
    May 17, 2011at7:18 am

    Internet Explorer 9 Su***…. i tried everything the guide you posted, the guide here: http://www.backspacetab.com/internet-explorer-9-crashes-in-windows-7/
    but nothing is working for me.

  • Kit Patterson

    Reply
    September 24, 2011at9:37 am

    For reference, this seems to now be fixed on IE9 (and IE10DP). I can’t reproduce it.

  • November 18, 2011at4:35 am

    Doesn’t crash my Internet Explorer 9.0.8112.16421 64-bit.

  • Jacob

    Reply
    April 8, 2013at10:56 pm

    This post is still somewhat relevant! Perhaps this specific one-liner won’t crash IE 9 at present, but I was just recently getting a myserious IE 9 crash. It turned out it was because of the removal of a CSS link containing an external font declaration, perhaps while it was in the middle of loading. IE 9 still seems to have flakiness when it comes to @font-face.

  • May 15, 2014at9:19 am

    Hi, great article can I ask does anyone really use Internet Explorer now apart from testing website builds etc? Be good to get your comments.

    Thanks

    Paul

Post a Comment