Skip to content

Internet Explorer : ”Operation aborted” Solution

If you ever worked with heavy JS codes or complex DHTML you may have already faced this error. This is like a nightmare. You are opening your web page. IE is loading the site. You see the progress bar. Suddenly you see a message “Internet Explorer cannot open the Internet site http://<Web site>.com. Operation aborted”. The dialog has only one button. so you press it. Then it shows “Page cannot be displayed”. You cannot even debug it. Cause you don’t see any source code. I searched many sites and forums. No one can say anything appropriately. See the MSDN site. They have some tips to avoid it. I don’t know how to reproduce it. But I’ll tell you a solution that worked for me. This solution works for me for jQuery javascript library.

In jQuery most initial operations are writen in domready block. That is,

jQuery(document).ready(

function(){

my_blah_blah_code();

}

);

The function there my_blah_blah_code() runs when DOM is ready. It means when all the elements is loaded in browser and its safe to manipulate it .

But I have seen its really not safe to manipulate it if we use the function jQuery(document).ready() block. You’ll say “No, its working for me”. Well then your lucky that its working. DOM also gives you a attribute in ‘body’ element. The ‘onload’ attribute. It always works. I never see it fails. Both ‘jQuery(document).ready()’ and ‘onload’ attribute gives the same functionality. But they are not same. To test it run a code like the following.

&amp;lt;script src="/path/to/jquery" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script type="text/javascript"&amp;gt;

jQuery(document).ready(

function(){

alert("jQuery domready fires");

}

);

&amp;lt;/script&amp;gt;

You’ll see which alerts later. Its the browser. See the live example here. So its safer to use ‘onload’. Thats why I am using here only ‘onload’. No jQuery(document).ready() block. I am replacing the jQuery ready block by this,

<html>
<head>
<script type="text/javascript" src="/path/to/jquery"></script>
<script type="text/javascript">
function by_blah_blah_code(){
// Write all your initialization code here.
}
</script>
<body>
<script type ="text/javascript" >
if(document.body){
 if(document.all){
 document.body.onload = by_blah_blah_code;
 }else{
 document.body.setAttribute("onload","by_blah_blah_code()");
 }
}else{
 alert("This code must be included after the body tag ;) ");
}
</script>
</body>
</html>

If you use it that way. You wont see any “operation aborted” error.

Best of luck.

© 2008 by A K M Mokaddim

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Ping.fm Post to StumbleUpon

{ 9 } Comments

  1. John V | December 16, 2008 at 10:27 pm | Permalink

    The main difference between jQuery(document).ready() and using onload=”" in the body, is that jQuery fires when the DOM is ready, and onload waits for everything to finish loading. That includes images, flash, etc.

  2. arun | January 8, 2009 at 4:02 am | Permalink

    thank you for this

  3. madjoe | January 14, 2009 at 10:06 pm | Permalink

    I’ve found the same issue with my IE6 browser, but unfortunately, jQuery code is not firing… here’s the code:
    http://pastebin.com/m6ee21b0b

  4. madjoe | January 14, 2009 at 10:19 pm | Permalink

    Ok, I’ve found it… I’ve corrected my code and now it works! Thanks for this post!

    Here’s the correction: http://pastebin.com/m43bfd48b

  5. Naveen | January 17, 2009 at 2:22 am | Permalink

    Thanks a ton for this suggestion. worked really great for me ..

  6. kiko | April 9, 2009 at 1:44 pm | Permalink

    Hello, this doesnt work for me?? this is my code. can anybody help….thanx
    http://pastebin.com/med6f137

  7. kiko | April 11, 2009 at 3:55 am | Permalink

    already fixed

  8. Shiplu | April 11, 2009 at 5:03 am | Permalink

    Kiko,
    A good practice to avoid such error would be to place your js code at the end of page. Not in tag. You can include any type of library in head tag. But the main code should be placed at the end of page.
    This is a tip from Yahoo!!

  9. Jason | December 2, 2009 at 5:41 pm | Permalink

    It is much better practice to use window.addEventListener(“load”) and window.onload to register your page load events. The result is the same as when assigning an onload attribute to the body element, but you won’t be messing with inline event calls.

{ 2 } Trackbacks

  1. Another | January 14, 2010 at 1:57 pm | Permalink

    Title…

    Very interesting post. I would like to link back to it….

  2. My Domain | February 4, 2010 at 7:23 pm | Permalink

    Joe…

    Check out my domain sometime….

Post a Comment

Your email is never published nor shared. Required fields are marked *