The Firebug [[Command Line]] provides these special functions for your convenience:

+

The Firebug [[Command Line]] provides these special functions for your convenience. These include functions to control the Firebug UI, functions interacting with the page, shortcuts for selectors and shortcuts for the [[Console API]]. Other browsers implement the Command Line API as well; the Chrome DevTools, Safari Inspector and Opera Dragonfly, implement most of what is below.

−

+

−

=== $(id) ===

+

−

Returns a single element with the given id.

+

=== [[help]] ===

+

Returns a list of Command Line API commands including short descriptions.

−

=== $$(selector) ===

+

=== [[$|$(selector)]] ===

+

Returns a single element matching the given CSS selector.

+

+

In old Firebug versions, this used to be equivalent to document.getElementById.

+

+

=== [[$$|$$(selector)]] ===

Returns an array of elements that match the given CSS selector.

Returns an array of elements that match the given CSS selector.

−

=== $x(xpath) ===

+

=== [[$x|$x(xpath)]] ===

Returns an array of elements that match the given XPath expression.

Returns an array of elements that match the given XPath expression.

−

=== $0 ===

+

=== [[$0]] ===

−

The currently-selected object in the inspector.

+

Represents the last element selected via the [[Inspector]].

−

=== $1 ===

+

=== [[$1]] ===

−

The previously-selected object in the inspector.

+

Represents the second last element selected via the [[Inspector]].

−

=== $n(index) ===

+

=== [[dollar-underscore|$_]] ===

−

Access to an array of last 5 inspected elements.

+

Returns the value of the most recently evaluated expression in the [[Command Line]].

−

=== dir(object) ===

+

=== [[$p]] ===

−

Prints an interactive listing of all properties of the object. This looks identical to the view that you would see in the DOM tab.

+

A container of arbitrary JavaScript values, after right-clicking them and selecting "Use in Command Line".

−

=== dirxml(node) ===

+

=== [[$n|$n(index)]] ===

−

Prints the XML source tree of an HTML or XML element. This looks identical to the view that you would see in the HTML tab. You can click on any node to inspect it in the HTML tab.

+

Returns one of the 5 last elements selected via the [[Inspector]]. This method takes one required parameter <code>index</code>, which represents the index of the element (starting at 0).

−

=== cd(window) ===

+

=== [[dir|dir(object)]] ===

+

Prints an interactive listing of all properties of the object. This looks identical to the view that inside the [[DOM Panel]].

+

=== [[dirxml|dirxml(node)]] ===

+

Prints the XML source tree of an HTML or XML element. This looks identical to the view inside the [[HTML Panel]]. You can click on any node to inspect it in the HTML panel.

+

+

=== [[cd|cd(window)]] ===

By default, command line expressions are relative to the top-level window of the page. cd() allows you to use the window of a frame in the page instead.

By default, command line expressions are relative to the top-level window of the page. cd() allows you to use the window of a frame in the page instead.

−

=== clear() ===

+

=== [[clear|clear()]] ===

Clears the console.

Clears the console.

−

=== inspect(object[, tabName]) ===

+

=== [[copy|copy(object)]] ===

−

Inspects an object in the most suitable tab, or the tab identified by the optional argument <code>tabName</code>.

+

Copies the given parameter to the clipboard. This can be a return value of a function or an object.

−

The available tab names are "html", "css", "script", and "dom".

+

=== [[inspect|inspect(object[, panelName])]] ===

+

Inspects an object in the most suitable panel, or the panel identified by the optional argument <code>panelName</code>.

−

=== keys(object) ===

+

The available tab names are "html", "stylesheet", "script", and "dom".

+

+

=== [[keys|keys(object)]] ===

Returns an array containing the names of all properties of the object.

Returns an array containing the names of all properties of the object.

−

=== values(object) ===

+

=== [[values|values(object)]] ===

Returns an array containing the values of all properties of the object.

Returns an array containing the values of all properties of the object.

−

=== debug(fn) ===

+

=== [[include|include(url[, alias]) / include(alias)]] ===

+

Includes a remote script.

+

+

=== [[debug|debug(fn)]] ===

Adds a breakpoint on the first line of a function.

Adds a breakpoint on the first line of a function.

−

=== undebug(fn) ===

+

=== [[undebug|undebug(fn)]] ===

Removes the breakpoint on the first line of a function.

Removes the breakpoint on the first line of a function.

−

=== monitor(fn) ===

+

=== [[monitor|monitor(fn)]] ===

−

+

Turns on logging for all calls to a function.

Turns on logging for all calls to a function.

−

=== unmonitor(fn) ===

+

=== [[unmonitor|unmonitor(fn)]] ===

Turns off logging for all calls to a function.

Turns off logging for all calls to a function.

−

=== monitorEvents(object[, types]) ===

+

=== [[monitorEvents|monitorEvents(object[, types])]] ===

−

Turns on logging for all events dispatched to an object. The optional argument <code>types</code> may specify a specific family of events to log. The most commonly used values for <code>types</code> are "mouse" and "key".

+

Turns on logging for all events dispatched to an object. The optional argument <code>types</code> may define specific events or event types to log.

Revision as of 15:57, 21 November 2013

The Firebug Command Line provides these special functions for your convenience. These include functions to control the Firebug UI, functions interacting with the page, shortcuts for selectors and shortcuts for the Console API. Other browsers implement the Command Line API as well; the Chrome DevTools, Safari Inspector and Opera Dragonfly, implement most of what is below.