Internet Explorer cannot open the Internet site: Operation Aborted
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.

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>
on May 29th, 2008 at 5:30 am
“One way to circumvent the error is to wait till the entire page DOM has been rendered. You can do that with window.onload ”
No don’t do that. Use dom:loaded with the prototype framework or he jQuery alternative. DO NOT use onload because that means your javascript will only execute when the entire page has loaded (dom + all images, .js files, .css files, etc)… with the prototype and jQuery methods of dom:loaded you javascript will get executed the very moment dom has finished loading (which excludes images, css, etc).
Kind regards,
Scott
on June 6th, 2008 at 7:23 am
Just would like to thank you guys for this - you really saved me to become crazy solving this problem.
For me worked fine solution with prototype.js
Event.observe(document, ‘dom:loaded’, myFunctionName, false);
on June 24th, 2008 at 4:22 am
A simple but very effective way to provide Internet Explorer users some Firefox capacities concerning generated content.
For the Firefox users the working example solution here presented is good enough.
However, for both - Internet Explorer and Firefox users- we go for the window.onload solution.
A sample of a JavaScript dom manipulation relocated footer:
window.onload = function() {
newFooter=document.getElementById(”footer”).cloneNode(true);
document.getElementById(”footer”).style.display=”none”;
document.getElementById(”container”).appendChild(newFooter);
}
This footer, with an inline background image and CSS styling, and can be seen at my blog: http://web-standards-masters.blogs.sapo.pt/ .
Regards,
Rui Granadeiro
on July 9th, 2008 at 12:07 am
Nice article. I had pretty much come to the same conclusion about what caused this, but it’s nice to get confirmation.
I’ve found that a script doesn’t even need to append a document element. Even a seemingly innocuous Element.innerHTML = String can do it if it’s done right. Check this out:
document.getElementById(”titlespan”).innerHTML += ” |”;
document.getElementById(”titlespan”).innerHTML += “”;
document.getElementById(”titlespan”).innerHTML += “”;
document.getElementById(”titlespan”).innerHTML += ” |”;
document.getElementById(”titlespan”).innerHTML += “”;
document.getElementById(”titlespan”).innerHTML += “”;
Now you might ask why someone would write a JavaScript to write HTML instead of just writing the HTML. And I might answer, “who the —- knows?” In this case I could find no reason. Not only that, the HTML itself added nothing of any value to the document. But the real kicker is that they thought it was more efficient to search the DOM tree SIX TIMES than to declare one variable to hold a string!!!
In this case I think IE was just rewarding the developer’s ineptitude.
on July 9th, 2008 at 12:12 am
Sorry the code doesn’t show above. I should have encoded some of the HTML.
In case you’re wondering, the script just inserted some span elements, complete with styling, that were either empty or contained a nicely styled pipe character.
on July 15th, 2008 at 5:32 am
Another fix to the problem, if you do not want to wait for the onload or dom:loaded event to fire, is to place a wrapper/dummy element in your html before the javascript is processed, and append your dom element to that instead of the body element.
I had the same problem, and fixed it with:
document.getElementById(’dummyElm’).appendChild(elm);
or since I am using prototype.js it was really:
$(’dummyElm’).appendChild(elm):
instead of:
document.body.appendChild(elm);
on August 1st, 2008 at 10:33 pm
I definitely have this problem on my sites, (several of them) didn’t realize it until I was on a friends computer. I’m not a techie so I really don’t understand the solution other than I think I comprehend the window.onload solution. Would someone explain for me or give an example of the other solutions.
Thanks, one of my sites that does this is www.compressed-air-car.com
thanks in advance
on August 1st, 2008 at 10:41 pm
Hello, sudently this error starte to happen out of nowhere, pages that I was 5 minutes before started to give me the error after that, what could have happened? Also, all those codes where should they go? Where do I write them?
Thank you
on August 2nd, 2008 at 9:42 am
This is greek to me. I can’t load my home page. Can someone give me a script to place on my homepage to fix this error? And where di I put it?
Thanks,
Andy
on August 22nd, 2008 at 5:42 pm
Outstanding, thank you for the fix. The only post I’ve seen that cuts through to the cause and solution. Funny article too.
on August 23rd, 2008 at 5:52 am
Thanks a lot mate, u saved hours for me
on August 27th, 2008 at 9:03 pm
I cannot load my home page which is google. I keep getting the IE error. My problem is I have no idea what is being discussed as a way to correct the problem.
Any solutions for a technical dummy?
on August 28th, 2008 at 12:14 pm
For Charlie and others asking how to fix sites they visit.
The only thing you can do is download Firefox or Safari and use it for those sites that are giving you trouble in Internet Explorer.
You are not able to use what is talked about in this article to stop Internet Explorer from giving you this problem. All you can do is e-mail the owner of the site and tell them you have this problem and point them to this article as a potential way to fix it. They have to fix their own website, you will not be able to do it. There is no magic bullet script you can install to fix this.
on August 29th, 2008 at 8:50 pm
I am trying to get the error code fixed as well. IE6 is aborting operation for the script prototype.js
I am using the lightbox2 effect for images. But IE6 doesn’t like the prototype script.
Will see if I can get it fixed..
on August 29th, 2008 at 9:21 pm
I fixed my problem, I moved my script from the “head” section to just above “/html” and everything stopped failing in IE!
:)
on September 10th, 2008 at 5:58 am
I put the following lines betweend script tags:
Event.observe(document, ‘dom:loaded’,
function init() {
–OLD JAVASCRIPT CODE GOES HERE–
}, false
);
Works perfectly. Thank you very much!
on September 15th, 2008 at 11:54 pm
I ran across another cause of this problem: I had my javascript accidentally placed within tags. This attempted hyperlink is ignored by all other browsers, but it causes this error in IE.
Hope that helps someone out there as clueless as me…
on January 14th, 2009 at 3:16 pm
Your fixed was very helpful. This is yet another reason why internet explorer makes designers life so hard. Microsoft, your worth billions and you have possibly the largest staff of developers in the world… You can do better, much better!
As for the problem and solutions, I will always use window.onload from now on, this is easy and quick.
on January 28th, 2009 at 8:26 pm
okayyy, i really have read it all. I understand every thing- except where do i put all of these codes. PLEASE HELP(:
on February 4th, 2009 at 5:57 pm
I think a lot of developers are faced with issues surrounding this bug Microsoft created in their releases.
Dare I say i’d expect more from a corporate company though roughly 93% of people still visit my websites with IE 7 > so we have to cater for Microsoft’s mistakes.
Firefox / Safari. One day people will realise =]
Jessciaa(:
“okayyy, i really have read it all. I understand every thing- except where do i put all of these codes. PLEASE HELP(:”
If you have a footer thats ends the div your currently inside, place the below the closing but before the and
Email me if your still stuck, im@chrisbalchin.co.uk
on February 25th, 2009 at 1:39 pm
The best solution would be if we (site owners) all refuse to work around Microsoft’s bug (which they know about and refuse to fix). See how long it takes before they themselves find themselves seeing this bug day in and day out around the web. They’ll soon fix it.
They’ve acknowledged in various MSDN threads that they know about the problem, and it’s their opinion that us web developers “shouldn’t be doing that”. Strange that all other browsers consider it a valid thing to do and are capable of handling it.
They have decided to do something about it in IE8 by the way. Instead of it (almost) crashing the browser, they’re going to throw an exception. If that exception isn’t caught then the user (depending on their settings) may get to see JS error. If it is caught, they’ll see nothing, but also the operation will have failed - which isn’t much better than operation aborted in my opinion.
I’ve tried convincing MS that this should he handled but they remain unconvinced. The only way to change their minds is if we all stop pandering to their bullshit and working around them.
on March 3rd, 2009 at 11:12 pm
try set defer=”defer”.
Example:
I hope this helps you
on March 20th, 2009 at 5:15 pm
You’re my hero, man. I’d been tearing my hair out for three hours trying to fix what I thought was a problem with a third-party jQuery plugin I was working with and it was just this.
God bless you, sir. :)
on April 9th, 2009 at 4:19 pm
You’re also -My- hero ! Many hours to search the web and put try-catch or alert() everywhere in my (very long) code.. and as Radical Bender said, it was just this.. I love you as much as I hate IE !
I was Unable to find it, even with visual studio 2005 witch sent me far away from something like this
(plz excuse my poor english)
on April 15th, 2009 at 1:51 am
I’m having the same error with IE 6 and IE 7. But I’m not able to reproduce it regularly. I’m using Dojo toolkits for generating some Bar Charts.There we have something called dojo.addOnLoad which will be called once the markup is ready.
If it’s the problem with script then why am I not able to reproduce it regularly?
on June 12th, 2009 at 6:23 am
Thanks a million - saved me the job…