Operation aborted

So I’ve been hacking some banners recently and encountered a weird error in Internet explorer (first in IE6, after testing the case also in IE7). While executing some Javascript code everything is executed normally but the thing pops an alert with ‘Operation aborted‘ message.

The case consists of a html page that includes a script from some other server that in turn loads another script from the same server. The reason to have so many scripts is that you can’t touch the html so what you have there has to be static, the second script includes configuration and the third script (that can easily be cached by browsers) includes all the code.

While trying to create and append a new element to the body element the thing broke with the afore mentioned message. After testing in other browsers I figured it’s probably not a domain issue (my first thought that made me think that the problem might be unsolvable). After that it was as easy as isolating the error – the code creates an element, adds some properties, adds content via innerHTML and then attaches it to the body element. Attaching was the culprit.

I don’t actually know what made me defer the function with setTimeout but that solved the problem. What I did was instead of calling the function immediately I used a setTimeout(fname,1); to move the function execution from the current “thread” to a new “thread”. I’m guessing that something isn’t ready yet after all the loading of scripts so IE gets annoyed.

I hope it helps. If it doesn’t you might want to check Operation aborted by Shaun Inman.

Leave a Reply