Command Line API

From FirebugWiki

(Difference between revisions)
Jump to: navigation, search
m (Added 'table' command)
(10 intermediate revisions not shown)
Line 1: Line 1:
-
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) ===
+
 +
=== [[help]] ===
 +
Returns a list of Command Line API commands including short descriptions.
 +
 +
=== [[$|$(id)]] ===
Returns a single element with the given id.
Returns a single element with the given id.
-
=== $$(selector) ===
+
Warning: it will ultimately change to return the first match for the given CSS selector.
 +
 
 +
=== [[$$|$$(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) ===
+
=== [[$n|$n(index)]] ===
-
Access to an array of last 5 inspected elements.
+
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).
-
=== dir(object) ===
+
=== [[dir|dir(object)]] ===
-
Prints an interactive listing of all properties of the object. This looks identical to the view that you would see in the DOM tab.
+
Prints an interactive listing of all properties of the object. This looks identical to the view that inside the [[DOM Panel]].
-
=== dirxml(node) ===
+
=== [[dirxml|dirxml(node)]] ===
-
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.
+
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(window) ===
+
 +
=== [[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.
-
==== Firebug types ====
+
=== [[unmonitorEvents|unmonitorEvents(object[, types])]] ===
-
<p>"composition", "contextmenu", "drag", "focus", "form", "key", "load", "mouse", "mutation", "paint", "scroll", "text", "ui", and "xul".</p>
+
Turns off logging for all events dispatched to an object. The optional argument <code>types</code> may define specific events or event families, for which to turn logging off.
-
==== Webkit types ====
+
For a list of available event families see [[monitorEvents|monitorEvents(object[, types])]].
-
* type <code>mouse</code> to monitor all ''mousedown'', ''mouseup'', ''click'', ''dblclick'', ''mousemove'', ''mouseover'', ''mouseout'', ''mousewheel'' events
+
-
* type <code>key</code> to monitor all ''keydown'', ''keyup'', ''keypress'', ''textInput'' events
+
-
* type <code>touch</code> to monitor all ''touchstart'', ''touchmove'', ''touchend'', ''touchcancel'' events.
+
-
* type <code>control</code> to monitor all ''resize'', ''scroll'', ''zoom'', ''focus'', ''blur'', ''select'', ''change'', ''submit'', ''reset'' events.
+
-
* an undefined types argument will monitor all of the above plus ''load'', ''unload'', ''abort'', ''error'', ''select'', ''change'', ''submit'', ''reset'', ''focus'', ''blur'', ''resize'', ''scroll'', ''search'', ''devicemotion'', ''deviceorientation'' events.
+
-
=== unmonitorEvents(object[, types]) ===
+
=== [[profile|profile([title])]] ===
-
Turns off logging for all events dispatched to an object.
+
Turns on the JavaScript profiler. The optional argument <code>title</code> contains the text to be printed in the header of the profile report.
-
=== profile([title]) ===
+
=== [[profileEnd|profileEnd()]] ===
-
Turns on the JavaScript profiler.  The optional argument <code>title</code> would contain the text to be printed in the header of the profile report.
+
-
 
+
-
=== profileEnd() ===
+
Turns off the JavaScript profiler and prints its report.
Turns off the JavaScript profiler and prints its report.
-
=== table(data[, columns]) ===
+
=== [[table|table(data[, columns])]] ===
This is a shortcut for <code>[[Console API#console.table.28data.5B.2C_columns.5D.29|console.table()]]</code>.
This is a shortcut for <code>[[Console API#console.table.28data.5B.2C_columns.5D.29|console.table()]]</code>.
 +
 +
=== [[traceCalls|traceCalls(fn)]] ===
 +
Enables tracing of specific function calls.
 +
 +
=== [[untraceCalls|untraceCalls(fn)]] ===
 +
Disables tracing of specific function calls.
 +
 +
=== [[traceAll|traceAll()]] ===
 +
Enables tracing of function calls for a whole context.
 +
 +
=== [[untraceAll|untraceAll()]] ===
 +
Disables tracing of function calls for a whole context.

Revision as of 01:25, 6 November 2012

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

help

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

$(id)

Returns a single element with the given id.

Warning: it will ultimately change to return the first match for the given CSS selector.

$$(selector)

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

$x(xpath)

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

$0

Represents the last element selected via the Inspector.

$1

Represents the second last element selected via the Inspector.

$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).

dir(object)

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

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(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.

clear()

Clears the console.

copy(object)

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

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".

keys(object)

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

values(object)

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

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

Includes a remote script.

debug(fn)

Adds a breakpoint on the first line of a function.

undebug(fn)

Removes the breakpoint on the first line of a function.

monitor(fn)

Turns on logging for all calls to a function.

unmonitor(fn)

Turns off logging for all calls to a function.

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.

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]).

profile([title])

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

profileEnd()

Turns off the JavaScript profiler and prints its report.

table(data[, columns])

This is a shortcut for console.table().

traceCalls(fn)

Enables tracing of specific function calls.

untraceCalls(fn)

Disables tracing of specific function calls.

traceAll()

Enables tracing of function calls for a whole context.

untraceAll()

Disables tracing of function calls for a whole context.

Personal tools