Gary Haran.com


Internet Explorer cannot open the Internet site: Operation Aborted

Posted in Programming by gary.haran on the April 22nd, 2008

This is perhaps the most dreaded of all Internet Explorer errors. It’s shrouded in mystery as even the ancient Microsoft Script Debugger cannot help you deal with it.

Operation Aborted

Working example

If you have Internet Explorer 7 give it a shot and see your operation aborted error in all it’s glory.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
  <head>
    <title>Internet Explorer cannot open the Internet site: Operation Aborted.  Sample error.</title>
  </head>
  <body>
    <table>
      <script>
        document.body.appendChild(document.createElement('div'))
      </script>
    </table>
  </body>
</html>

Why it fails

Internet Explorer doesn’t like scripts appending elements to the existing DOM, especially when the script tag is inside ul, ol, table, form, blockquote, and various other tags…. When Internet Explorer fails it fails spectacularly by shutting down the script engine and aborting page rendering.

Solution(s)

One way to circumvent the error is to wait till the entire page DOM has been rendered. You can do that with window.onload or if you prefer using Prototype Javascript Framework you can get away by launching the DOM operation with dom:loaded.. jQuery has the ready method but numerous frameworks come with their own implementation.

Here is the sample solution to the internet explorer operation aborted using window.onload.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
  <head>
    <title>Internet Explorer cannot open the Internet site: Operation Aborted.  Error: sample solution.</title>
  </head>
  <body>
    <ul>
      <script>
        window.onload = function(){
          document.body.appendChild(document.createElement('div'))
        }
      </script>
    </ul>
  </body>
</html>

Leave a Reply