Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  114] [ 5]  / answers: 1 / hits: 94200  / 15 Years ago, mon, may 25, 2009, 12:00:00

Let's say I accidentally wrote this:



 do { } while (true);


...and then ran it. Apart from killing your browser, is there a way to stop javascript execution (the equivalent of Ctrl+Break in basic, or Ctrl+C)?



Normally, after about 30 seconds your browser asks if you want to stop the long-running script, but this doesn't always happen (as I just found out)!



FYI: A simple loop such as this: for (i=1; i > 0; ++i); will cause my browser to crash (Firefox 3.5b4). I don't feel much like testing to see if it's any of my add-ons. Continuously restarting my browser isn't my idea of a fun Monday night.


More From » javascript

 Answers
45

At least with Chrome, you may be able to kill off the individual tab and not the whole application.



Randolpho has also informed me that IE8 has similar functionality.


[#99465] Wednesday, May 20, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deanna

Total Points: 84
Total Questions: 86
Total Answers: 107

Location: Cyprus
Member since Wed, Dec 8, 2021
3 Years ago
;