views:

56

answers:

2

i'm getting dialogue box (Operation aborted)

What is the problem in this code?

<script type="text/javascript"> 
$(document).ready(function() {
$('.demo').popupWindow({ 
centerScreen:'1'
}); 
});
</script>
+2  A: 

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/

Kevin
is my given javascript code Ok?
metal-gear-solid
+2  A: 

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: http://stackoverflow.com/questions/1153534/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>
Josh
pls check each line of code provided by me. is it ok?
metal-gear-solid
@jitendra: As you provided it, the code is OK. Did my answer make sense, especially the part about calling your code right before the `</body>` tag?
Josh
I ran javascript debugger of Visual studio on my page and at my example code i'm getting error "<script> tag is not closed"
metal-gear-solid
@jitendra -- Well, that's a different issue. I'm not sure what's causing that, I'd need to see the full source file. With regards to *this* question, does calling the function to show the popup window right before the `</body>` tag solve *this* issue?
Josh