Sandra
Sandra

Reputation: 772

Is it possible to stop a javascript with Firebug without using breakpoints?

Is it possible with Firebug to stop a javascript with a press of a button or a keyboard shortcut instead of stopping it by setting a breakpoint?

Why would I like to do this? We have a very dynamic website with lots of animations. It would be a great help if I could just stop the scripts at the moment the animation is doing something I want to inspect. That would be a lot faster than fiddling with the breakpoints.

Upvotes: 18

Views: 17775

Answers (10)

Sebastian Zartner
Sebastian Zartner

Reputation: 20085

Firebug has different ways to stop the script execution without setting breakpoints at specific lines. These options are called Break On features.

In your case I see two relevant options:

  1. Break the JavaScript on the next executed line
    The Script panel has a Break On Next button (*Break On Next* button), which allows you to stop the script execution at the next executed JavaScript statement. This feature can also be enabled via the keyboard shortcut Ctrl+Alt+B.

    So, just hit the keyboard shortcut once the animation is at the point when you want to inspect it.

  2. Break on HTML mutation
    The HTML panel has a Break On Mutate button (*Break On Mutate* button), which allows you to stop the script execution at the next HTML mutation.
    There are also more fine grained options to stop at the mutation of a specific element, which are available within the context menu of the elements. Those options are:

    • Break On Attribute Change: Stops the script execution when an attribute of the element is added, changed or removed.
    • Break On Child Addition or Removal: Stops the script execution when a child node is added or removed.
    • Break On Element Removal: Stops the script execution when the element itself is removed.

    In your case Break On Attribute Change may be the right choice in case the animation changes the CSS within the style attribute of the element.

Upvotes: 3

Kasturi
Kasturi

Reputation: 3333

There is a pause button in Firebug. Clicking on that is what you are looking for.

Upvotes: 4

Matthias Urlichs
Matthias Urlichs

Reputation: 2524

If the web site is continually reloading content from your server, you can switch to the Net pane. The context menu there has a "Break on XHR" entry which, when checked, will stop your script whenever it tries to get new content.

Upvotes: 0

Marty
Marty

Reputation: 19

If you use the web developer plugin, you can disable all java script from running on the page then use firebug as you wish.

Upvotes: 1

uwanius
uwanius

Reputation: 1

The easiest way is to install the firefox extension "PrefBar". There you can add a checkbox "JavaScript". If you deactivate it, javascript stopped.

Upvotes: -1

Eric
Eric

Reputation: 1769

This is how I did it, from the web console (not the scratchpad), run:

window.addEventListener("keydown", function() {debugger;})

Then go back to the debugger tab. When you focus the document and press a key, the browser will pause JS.

Upvotes: 8

Pali Madra
Pali Madra

Reputation: 69

The best way to fix this is go to the HTML drop down which is there next the HTML tab in firebug. Deselect "highlight changes" and "scroll changes to view" and that should allow you to inspect the html and css code that is being executed. I hope you guys wanted to do this.

Upvotes: 0

Tracker1
Tracker1

Reputation: 19334

If you know where it's doing something you want to inspect, then what is wrong with breakpoints? Also, you can use the debugger keyword in the code, or you can inject console.log/debug/warn/info statements in your code. (You can stub out the console object for those environments that don't have one).

Upvotes: 2

Matt Lohkamp
Matt Lohkamp

Reputation: 2191

depending on the animation library you're using, there might be a 'stop all animations' method - jQuery's .stop(), for instance. how are you handling the animations?

Upvotes: 1

psychotik
psychotik

Reputation: 39009

From what you describe, I'm guessing javascript console logging from your code might help you best. Check out http://getfirebug.com/wiki/index.php/Console_API.

Upvotes: 1

Related Questions