views:

1489

answers:

5

I recently added JQuery's date-picker control to a project. In Internet Exploder, I get the following error message:

Internet Explorer cannot open the Internet site

http://localhost/

Operation aborted

What is causing this problem?

+10  A: 

There was a related question earlier today:

Operation Aborted Error in IE

This is a common problem.

It occurs in IE when a script tries to modify the DOM before the page is finished loading.

Take a look at what sort of scripts are executing. You'll find that something is getting started before the page is finished loading. You can use the window.onload event to correct the problem (or one of the onDomReady library functions).

keparo
A: 

This comes up a lot with Google Maps (used to drive me bonkers because it's hard to debug). One simple solution is to add the defer attribute to your script tags. They don't validate that way, but hey, this is real life we're talking about.

Andrew Hedges
Hey Andrew. I wonder if this should read: "... this is my LIFE we're talking about."
keparo
They validate fine - http://www.w3.org/TR/REC-html40/interact/scripts.html#adef-defer . Of course, defer="defer" is needed if you happen to be using XHTML.
bobince
A: 

I was able to fix this problem on a few pages I was having trouble with today.

If you have JavaScript that modified the DOM anywhere within the body of the page, try moving it below the </body> tag.

Example:

Change

...
<script>highlightSearchTerms();</script>
</body>
</html>

To

...
</body>
<script>highlightSearchTerms();</script>
</html>
T Pops
A: 

Just elaborating Keparo's answer.

You can put your script inside one of the following functions(as per the library you are using) and that will resolve the issue.

prototype.js:
document.observe(’dom:loaded’, function () { /* your script goes here */ }),

jquery:
jQuery(document).ready(function () { /* your script goes here */ })

mootools:
document.addEvent(’domloaded’, function () { /* your script goes here */ })