3

It is possible for javascript to get stuck in a loop of opening up alerts. For example:

for(var i=0;;i++)
    alert('This will never stop');

Is there a way to gracefully stop this in firefox, without having to kill the whole process?

2
  • 1
    This isn't a satisfactory general-purpose solution, but with Greasmonkey (or maybe Ubiquity or Jetpack) you could overwrite window.alert with a function that calls window.confirm and optionally throw()s an error, stopping all script execution, or toggles a flag to stop alerts. That might be useful if a site you keep going back to presents this behavior.
    – Anonymous
    Commented Jan 7, 2010 at 14:56
  • In Opera, each dialog has a checkbox saying "Stop executing scripts on this page", which when checked will solve the problem. Guess they should put it in firefox too.
    – Anand
    Commented Jan 8, 2010 at 6:01

5 Answers 5

4

perhaps the 'NoScript' plugin could help. Ban the site and the script won't be executed at all

1

Stackoverflow question reference: How do you stop an infinite loop in Javascript?

A critical difference in your loop is the pop-up (user interaction) that prevents the "slow-script" detection.

1

If you're quick enough with it, click "Ok" then hit F5. You may have to confirm one or two more popups, but the page will reload and you'll be saved.

1
  • 3
    Page reload is useless if the rogue JS script runs when loading the page (a case I had). But you inspired me to do [Ctrl+] Return and Ctrl+W in a quick sequence and finally I got rid of the page... (Ctrl+Return works as Return but having this key down helps for speed hit Ctrl+W!) So +1 for you! :-)
    – PhiLho
    Commented Mar 15, 2010 at 15:34
1

I usually have the Javascript popup in focus so that I can just hit Enter to get rid of it. Then, I position my mouse cursor just above the Close Tab button. I then begin a race where I hit Enter to close the popup and immediately click the Close Tab button before it has a chance to create another popup.

0

I'm using AlertStopper (https://addons.mozilla.org/af/firefox/addon/13530/) myself.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .