Internet Explorer 8: Operation Aborted?

Have you ever seen this dialog (see pic on right side) while surfing the web in Internet Explorer? You browse to your favorite news site. The content starts loading, you've already started reading the headline, and then it happens. Those of you familiar with the operation aborted dialog know that it spells sudden doom for […]

Have you ever seen this dialog (see pic on right side) while surfing the web in Internet Explorer? You browse to your favorite news site. The content starts loading, you've already started reading the headline, and then it happens. Those of you familiar with the operation aborted dialog know that it spells sudden doom for the website you're currently viewing. Unsuspecting users have no idea what it means and simply click 'OK' and then watch in horror as the web page they were just reading disappears; only to be replaced by an navigation error screen. More savvy users move the dialog out of the way so that they can finish reading what was visible before they too accept the inevitable...

This dialog (and its side-effects) is gone in Internet Explorer 8 Beta 1.

What caused the operation aborted error?

The operation aborted dialog in Internet Explorer 7 is triggered by an HTML parsing exception that occurs when all the following specific conditions are met:

  1. The HTML file is being parsed
  2. Script is executing
  3. The executing script attempts to add, or remove an element from an unclosed ancestor in the markup tree (not including the script block's immediate parent element).

You can see that each of these conditions is true in the following example markup:

&lt;html&gt;&nbsp; <br />&lt;body&gt;&nbsp; <br />&nbsp;<font color="#800080"> &lt;div&gt; <br /></font>&nbsp;&nbsp; &lt;script type="text/javascript"&gt; <br />var newElem = document.createElement('foo'); <br />&nbsp;&nbsp;&nbsp; document.<font color="#800080">body.appendChild</font>(newElem); <br />&nbsp;&nbsp; &lt;/script&gt; <br />&nbsp; &lt;/div&gt; <br />&lt;/body&gt; <br />&lt;/html&gt;

The HTML file is being parsed, and encounters a script block. The script block contains inline script which creates a new element and attempts to add it to the BODY (document.body.<font color="#800080">appendChild</font>(newElem)) element before the closing BODY tag has been encountered by the parser. Note that if I removed the highlighted DIV element, then this problem would not occur because the script block's immediate parent would be BODY, and the script block's immediate parent is immune to this problem.

Full Article

Microsoft, IE8, Internet Explorer 8, Developers, Knowledgebase