views:

5600

answers:

5

I am developing a site that makes extensive use of JavaScript (jQuery). I regularly get the IE 'Stop running this script?' error dialog when I try to close the browser.

I'm guessing the problem occurs because the site is a single page that uses AJAX, so there are no postbacks to reset IE's count of commands executed.

Client-side registry hacking is not an option.

Does anyone know a way to get around this error?

UPDATE: The page has a number (~10) interval timers that poll continually on 30 or 60 second intervals.

+2  A: 

Do you by chance use a window.onunload handler? If you do, you might check that you don't have an infinite loop in there.

To check, at the bottom of your javascript do:

window.onunload = null;

and test again.

Eric Wendelin
+1  A: 

You just have some long running script/infinite loop in your code. More details might get a more precise answer.

If your page is using lots of intervals then you'll want to cancel them before navigating away from the page. Use window.onunload to clear all of the intervals.

thenduks
+2  A: 

You might want to look at the answers posted for the question "a script on this page is causing ie to run slowly".

wrumsby
A: 

Hi, i also faced this issue,i overcome this issue by dividing the continues dom execution , for this i used setTimeout function,resolving this issue is completely depends on how you are dividing the continuous execution

Narsi
A: 

Hi All,

I just blogged about this and put what I think is a pretty stylish solution. So have a look. As mentioned above my solution just breaks up long running operations into chunks but I provide a nice utility class to do this.

Thanks

Guido

gatapia