8

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.

liammclennan
  • 5,295
  • 3
  • 34
  • 30
  • You might want to look at the answers posted for the question "[a script on this page is causing ie to run slowly](http://stackoverflow.com/questions/212550/a-script-on-this-page-is-causing-ie-to-run-slowly)". – Walter Rumsby Nov 18 '08 at 05:11

8 Answers8

4

I have also faced this issue and had overcame this issue by dividing the continous DOM executio. For this approach, I used setTimeout function. Resolving this issue completely depends on how you are dividing the continuous execution.

momo
  • 21,233
  • 8
  • 39
  • 38
Narsi
  • 41
  • 1
3

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
  • 43,147
  • 9
  • 68
  • 92
2

Problem: “Stop running this script?” error

Solution: You can say this a compatibility issue or a bug as the same stuff runs without any error in Mozilla but it runs in IE 6,7 or 8 with an error message "Stop running this script". Microsoft has provided a patch to fix this issue in IE. So, please go to the following link and download the "Microsoft Fix It" and install the same and restart the browser and you will never see the "Stop running this Script" error: http://support.microsoft.com/kb/175500#FixItForMeAlways

PengOne
  • 48,188
  • 17
  • 130
  • 149
  • 5
    This is not really a solution. Users shouldn't have to install a patch just to view a certain website in their browser. A few `setTimeout` calls is all that's needed to fix this problem. Users shouldn't have to install patches to fix web developers' code (no offence to web developers). – gen_Eric Sep 23 '11 at 13:50
1

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.

gen_Eric
  • 223,194
  • 41
  • 299
  • 337
gatapia
  • 3,574
  • 4
  • 40
  • 48
1

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.

rfunduk
  • 30,053
  • 5
  • 59
  • 54
0

Like the person who mentioned $("*"), try not to use $(this) as a bind selector for custom events, this caused a recent script of mine to destroy the load times of the system.

Destreyf
  • 441
  • 5
  • 7
0

May also consider split the long operation into $(document).ready() and $(window).load()

ThiamTeck
  • 385
  • 1
  • 9
0

I just had an issue with jquery selectors that were too general: e.g. $("*")

ripper234
  • 222,824
  • 274
  • 634
  • 905