Dealing with IE "Operation Aborted". Or, how to Crash IE
It's easy to create runtime errors in JavaScript. But it's not every day you find a way to crash the runtime entirely.
It looks so innocent, yet it is so delightfully evil... copy/paste this into a simple HTML file and open it.
<html>
<head>
<script type="text/javascript">
function appendToBody() {
var span = document.createElement('span');
document.body.appendChild(span);
}
</script>
</head>
<body>
<form>
<script type="text/javascript">
appendToBody();
</script>
</form>
</body>
</html>
This is what you see:
For the search engines: "Internet Explorer cannot open the Internet site", "Operation aborted" :)
Upon clicking the one and only thing you can click on, your page is completely replaced with this...
"The page cannot be displayed"
Unfortunately the error isn't very helpful, so if you run into this you will likely scratch your head searching for an answer. You'll probably find suggestions like "reinstall IE" or "use Firefox". Don't listen to that nonsense :)
The problem is you can't append to the BODY element from script that isn't a direct child to the BODY element.
If you research it enough, you will find that some people ran into this when they had script inside a <table>. The proposed fix was to move the script outside the <table> element. But that would only work if the <table> was a direct child to the body! If the table is inside yet another element, it will still fail.
And of course, it's ok if your script isn't a direct child of BODY as long as it doesn't execute inline while the page is being parsed. So for our example here, you could fix it by moving the script to the top or bottom of the body, moving it after the body, or putting it in a function and calling it from window.onload or in response to some other event.
With AJAX apps becoming ever more popular, DOM manipulation is becoming more commonplace, and I fear more and more people may run into this. Hopefully this helps.