IE Says “Internet Explorer cannot open the Internet Site ________. Operation Aborted.” I Say “WTF?”

By  on  

During the development of a recent website, I fitted the site with some awesome MooTools effects. Per usual, I would check each page with Firefox and once the page looked good, I'd switch over to Internet Explorer to make sure the site looked the same. That's where the problem began.

Periodically, I would get a JavaScript-like alert box that said "Internet Explorer cannot open the Internet Site ________. Operation Aborted," as show below:

After doing some research, I found a post by MooTools dev Aaron Newton that explained why the problem was occuring:

IE does this when you attempt to modify a DOM element before it is closed. This means that if you try and append a child element to another and that other element (like the document.body) is still loading, you'll get this error. This will occur if you use .appendChild (which in Mootools includes .adopt, .injectInside, .injectBefore, etc.) or if you use Element.innerHTML = "" (or in Mootools, the .setHTML method).

The fix is quite simple: don't do any processing until the DOM is ready.

window.addEvent('domready', function(){
  //do stuff
});

Click here to read Aaron's full post. The moral of the story is not to modify elements that haven't fully loaded!

Recent Features

  • By
    Create a Sheen Logo Effect with CSS

    I was inspired when I first saw Addy Osmani's original ShineTime blog post.  The hover sheen effect is simple but awesome.  When I started my blog redesign, I really wanted to use a sheen effect with my logo.  Using two HTML elements and...

  • By
    Serving Fonts from CDN

    For maximum performance, we all know we must put our assets on CDN (another domain).  Along with those assets are custom web fonts.  Unfortunately custom web fonts via CDN (or any cross-domain font request) don't work in Firefox or Internet Explorer (correctly so, by spec) though...

Incredible Demos

  • By
    Facebook-Style Modal Box Using MooTools

    In my oh-so-humble opinion, Facebook's Modal box is the best modal box around. It's lightweight, subtle, and very stylish. I've taken Facebook's imagery and CSS and combined it with MooTools' awesome functionality to duplicate the effect. The Imagery Facebook uses a funky sprite for their modal...

  • By
    Basic AJAX Requests Using MooTools 1.2

    AJAX has become a huge part of the modern web and that wont change in the foreseeable future. MooTools has made AJAX so simple that a rookie developer can get their dynamic pages working in no time. Step 1: The XHTML Here we define two links...

Discussion

  1. I’m curious about why Firefox didn’t throw an error in this case and IE did. Is it Javascript execution speed perhaps?

  2. I have no idea Eric. Maybe Firefox “queues” the instructions until the DOM is set.

  3. Oh! Wonderful job!
    Very good and useful post.
    I add your interesting blog in my iGoogle page!

  4. Alejandro

    Great post. 100% useful. I fixed a bug thanks to this. Thanks so much!!!

  5. Thanks a lot man; this saved me ages of headache.

  6. Davin

    Thanks Man!

  7. NIce man. I’m using Prototype. Here’s the syntax for it

    Event.observe(document, "dom:loaded", function(){
    //put your stuff here :)
    });
  8. @#%*!! One particular page of mine worked fine, even on Virus Explorer. One day it just stopped working. Why? I don’t know. I assumed that someone else had changed something. Hey I even stripped all my stuff from it and it still wouldn’t let Virus Explorer load the page – it showed the message you discuss here.

    If the error message could have just said what was wrong, I would have fixed the problem. But because the message contains no information, I decided to just leave it. Internet Explorer users don’t need to see the page. Yup, that’s right, I’m not going to sit there for an hour with a copy of the page trying to figure out which line breaks it – knowing my luck, if I do that, someone will point me to some obscure Microsoft Knowledgebase article #34545645234 saying that it’s a feature of some kind to enhance the browsing experience, and not configurable from a web server.

    Developers, please put information into your error messages. On personal projects, I no longer code for Internet Explorer. It’s not “you should view this page in browser X” – really I don’t care which browser they use as long as they use a web browser. “Please do not view this page without a web browser”

  9. chriss

    i dont understand how to fix it

    WHAT?????????

  10. Snehasis Mohapatra

    Just put defer=”defer” on the script tag and the error will disappear.

  11. Alvaro Sanchez

    I was having the same error doing an Ajax call on mootools. It would load fine the first time but if you refresh it would give the error mentioned above. There is something about how IE handle the cached page. My solution? I appended a random number at the end of the page being called using Ajax. ( ‘URL_HERE?var=xxxx&foo=’+Math.random() )
    It fixed it for me.

  12. Anael Olmedo

    Ok, I have a JOOMLA site, the error comes when the user opens certain article, which contains an “ISSUU” catalog….

    THE QUESTION IS:
    “WHERE DO I PUT THIS CODE?” i dont know much about programing, i would apreciate any help.

  13. Interestingly, this error occured on only one of our sites’ homepages. Each is very similar, but the error occured on the Flash slideshow for only one site’s index page.

    I simply moved the ” to the header and the error stopped.

    I did try the ‘defer=”defer”‘ fix, but not having the Flash slideshow effect for 60-70% of our site visitors didn’t work for me.

    Your explanation of ‘modifying the DOM’ made me realize I needed to move the script.

    Thanks!!!

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!