Skip to content Skip to sidebar Skip to footer

Ie7 "operation Aborted" Even With Fastinit?

A piece of javascript code I'm working on is causing the nasty 'Operation Aborted' message in IE. I am well aware that you cannot modify the DOM until after it has loaded. Sure eno

Solution 1:

I'm not sure about FastInit, but I just answered a similar question about waiting for the DOM to be ready here:

Initiate onclick faster than with document.onload

Basically, you can do it in IE by using the defer attribute on your script tag:

<scripttype="text/javascript"defer></script>

This will delay parsing the script until after the DOM is ready.

Solution 2:

N.B. SO is playing silly buggers with the formatting; sorry about that.

The "Operation Aborted" error occurs when you try to modify the grandparent element of the script element. So, for example, the following code will cause it because the script is attempting to modify the body from a child div, meaning it is trying to modify its grandparent element:

<body><divid="foo"><scripttype="text/javascript">var newThing = document.createElement("div");
        /* ### The next line will cause the error ### */document.body.appendChild(newThing);
        <script>
    </div>
</body>

The same code changed to:

<body><divid="foo"></div><scripttype="text/javascript">var newThing = document.createElement("div");
    /* ### The next line will NOT cause an error ### */document.body.appendChild(newThing);
    <script>
</body>

would not cause the error, as the script is now modifying its parent, which IE can handle.

The most common reason for this happening is that you have failed to close a div (or other element) further up the page; find the missing close tag and you'll fix it. Alternatively, if your script actually is inside another element, move it out so it is a child of the body.

Solution 3:

Sorry...

window.onload = function() {
    // Your code??
}

Post a Comment for "Ie7 "operation Aborted" Even With Fastinit?"