开发者

What is the problem in this javascript code , getting "Operation aborted" in IE?

i'm getting dialogue box (Operation aborted)

What is the problem in this code?

<script type="text/javascript"> 
$(d开发者_JAVA技巧ocument).ready(function() {
$('.demo').popupWindow({ 
centerScreen:'1'
}); 
});
</script>


You get the "Operation aborted" message in IE when JavaScript tries to modify the DOM (the structure of the HTML page) before IE's rendering engine has finished processing it. The result is basically that the rendering engine crashes and you're taken away from the page to an "Operation Canceled" error page.

The widely posted solution is to wait until the DOM has loaded, using a tool like FastInit, prototype's $(document).observe('dom:loaded'), or jQuery's $(document).ready. But you are already using $(document).ready. So your code should work.

I asked basically the same question here: IE7 "Operation Aborted" even with FastInit?

I accepted @NickFitz's answer because not accepting an answer was causing my accept ration to go down and he provided the most useful information. Ultimately what I did was moved my script to right before the </body> tag, and that seemed to solve the issue. Try that and see if it works for you. If you can't actually move the script, wrap it in a function and call that function. I.E:

<script type="text/javascript"> 
var showDemoPopupWindow = function() {
  $('.demo').popupWindow({ 
    centerScreen:'1'
  });
}
</script>
...
</head>
<body>
...
...
<script type="text/javascript"> 
$(document).ready(showDemoPopupWindow);
</script>
</body>
</html>


Here are a couple of links describing the issue. It's specific to IE dealing with DOM manipulation.

http://support.microsoft.com/kb/927917

and

http://www.clientcide.com/code-snippets/manipulating-the-dom/ie-and-operation-aborted/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜