views:

59

answers:

5

Hi All,
  There is some problem code in a website I don't have source access to. Upon loading the page, something goes wrong (in my version of Win and FF at least) such that ajax calls are made repeatedly instead of just once. This quickly locks me out of firebug and pretty much everything else so that all I can do is close the tab.

  What I want is a simple button that I can quickly hit to stop executing scripts... yet for all my googling and poking about I can't seem to find one?? I can't set a break point in firebug as I get locked out really quick as it struggles with all the ajax calls...

  Surely I'm missing something simple here?

Lyle

A: 

Javascript is single threaded. This means you can't interrupt executing scripts.

akellehe
How is Javascript being single-threaded related to interrupting scripts?
Michael Mior
You can't interrupt a script running on a page with another script on that page.
akellehe
Understood :) Although that doesn't mean the browser can't interrupt scripts.
Michael Mior
Agreed, I've seen firefox do a popup before if it thinks a script has gone mad giving you the option to stop execution. Why there isn't a button for this is beyond me...
Cosmicnet
A: 

See NoScript.

NoScript is a Firefox extension that lets you block the problem site from running JavaScript while still allowing other sites to work as normal - no need for you to hit a button to stop it.

RichieHindle
I want to try to debug the code though.. disabling the javascript isn't good for me :/
Cosmicnet
+1  A: 

You can disable Javascript

Tool -> Option -> Content -> Disable Javascript (I'm on a French version at the moment, the name should be good though)

Or use NoScript

HoLyVieR
I'm aware of how to disable javascript, that isn't the question. I need to stop a script after it has started executing
Cosmicnet
+2  A: 

You can use Fiddler to hijack the JavaScript code with an autoresponder and comment out the part of code that is making all the calls so you can figure out what is going wrong.

epascarello
Yes! Not exactly what I was asking for, but instead even better :) I'll be able to set some proper break points in the js and figure out what's going on as if I had access to the source :D Think I'll be using this a lot, thanks very much for the pointer
Cosmicnet
+1  A: 

Firebug has a "Break on Next" button. It adds a breakpoint on the next execution of a script.

Break on Next

Chetan Sastry
This is the way to "kind of" stop javascript execution. It doesn't really stop it but it does pause execution for you to analyze what's going on and maybe get some insight into what's causing your infinite loop.
Juan Mendes
Hmmm this 'kind of' works for me, but it appears all the ajax calls are still happening, which slows things to a point it's impossible to work with :(
Cosmicnet