What is the “Operation Aborted” error in Internet

2019-02-09 07:00发布

问题:

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?

回答1:

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).



回答2:

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 */ })


回答3:

Found this possibly related blog post: http://blogs.msdn.com/ie/archive/2008/04/23/what-happened-to-operation-aborted.aspx

Or this: http://weblogs.asp.net/infinitiesloop/archive/2006/11/02/Dealing-with-IE-_2600_quot_3B00_Operation-Aborted_2600_quot_3B002E00_-Or_2C00_-how-to-Crash-IE.aspx

Seems to be pretty common



回答4:

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>


回答5:

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.