Galin Iliev's blog

Software Architecture & Development

"Internet Explorer cannot open the Internet site", "Operation aborted"

If you're web developer and write JavaScript/AJAX-driven web sites you probably have seen such message (in IE of course)... If you haven't seen it yet just save this as html file and open it in IE:

    <script type="text/javascript">
    function appendToBody() {
        var span = document.createElement('span');
        <script type="text/javascript">

The code is taken from blog post Dealing with IE "Operation Aborted". Or, how to Crash IE.

So as a rules of thumb for DOM manipulations inside browsers:

  • The problem is you can't append to the BODY element from script that isn't a direct child to the BODY element.
  • Do not place script inside <table> tags.
  • Do not try to manipulate with element in Javascript which are not loaded yet! (e.g div placed on the very bottom at the page and not loaded by browser at the time when JS function is executed).

These rules can save you many hours of guessing what's wrong...

Comments (2) -

  • Deyan Varchev

    12/2/2007 7:31:18 PM | Reply

    Good remarks on JS in pages. I would suggest that the last rule can be changed a little bit. As best practice - if you have any script manipulating HTML DOM, execute it after the page is loaded. To do that attach to window's object load event :

    else if (window.addEventListener)
      window.addEventListener('load', appendToBody, true);

    If it is more than just append one element you can wrap all operation in a Initialize() method.
    For those using ASP.NET Ajax, attaching to event is much simpler. The previous code will just be:

    $addHandler(window, 'load', appendToBody);

  • Anton Staykov

    12/12/2007 2:19:53 PM | Reply

    Or just the useful JS debugging tools like: FireBug on Mozilla FireFoz, or IEDevToolber on IE ;)
    Awesome tools - the right hand of JavaScript coder.
    And, may be the VS 2008 will offer good JS Debugging as well.