sometimes i use debug code to alert something in javascript (for example, matching something in regular expression), but forget a modifier and and the alert is in an infinite loop (or if the loop matches the pattern 300 times). If using Firefox, the alert keeps on coming out, and there is no way to even close the tab, the window, or the app.
If I force exit, it will close all the tabs and even other windows of Firefox… is there actually a way to stop the loop more gracefully?
The short answer is: No.
This is one good reason to use Firebug and the console.log function. Which, ironically, will cause the “stop script because it’s running away dialog” to not display in some cases, meaning you are right back where you are now.
Chrome and Opera have this feature. IE doesn’t, Apple Safari doesn’t either.
Not a native solution but you could try this grease-monkey script: http://www.tumuski.com/2008/05/javascript-alert-cancel-button/
Also, you could simply override the alert function to use a confirm dialog instead and stop showing alerts if the confirm is canceled:
And then: