Command Line API

From FirebugWiki

Revision as of 23:57, 21 November 2013 by Sebastianz (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.

Contents

[edit] help

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

[edit] $(selector)

Returns a single element matching the given CSS selector.

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

[edit] $$(selector)

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

[edit] $x(xpath)

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

[edit] $0

Represents the last element selected via the Inspector.

[edit] $1

Represents the second last element selected via the Inspector.

[edit] $_

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

[edit] $p

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

[edit] $n(index)

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

[edit] dir(object)

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

[edit] 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.

[edit] 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.

[edit] clear()

Clears the console.

[edit] copy(object)

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

[edit] inspect(object[, panelName])

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

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

[edit] keys(object)

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

[edit] values(object)

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

[edit] include(url[, alias]) / include(alias)

Includes a remote script.

[edit] debug(fn)

Adds a breakpoint on the first line of a function.

[edit] undebug(fn)

Removes the breakpoint on the first line of a function.

[edit] monitor(fn)

Turns on logging for all calls to a function.

[edit] unmonitor(fn)

Turns off logging for all calls to a function.

[edit] monitorEvents(object[, types])

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

[edit] unmonitorEvents(object[, types])

Turns off logging for all events dispatched to an object. The optional argument types may define specific events or event families, for which to turn logging off.

For a list of available event families see monitorEvents(object[, types]).

[edit] profile([title])

Turns on the JavaScript profiler. The optional argument title contains the text to be printed in the header of the profile report.

[edit] profileEnd()

Turns off the JavaScript profiler and prints its report.

[edit] table(data[, columns])

This is a shortcut for console.table().

[edit] traceCalls(fn)

Enables tracing of specific function calls.

[edit] untraceCalls(fn)

Disables tracing of specific function calls.

[edit] traceAll()

Enables tracing of function calls for a whole context.

[edit] untraceAll()

Disables tracing of function calls for a whole context.

[edit] getEventListeners()

Returns all the event listeners registered for specific node (event target).

Personal tools