This page describes how to add code to write messages to the Firebug console.
Contents |
Introduction
Use the Firebug console to log information about a web page.
Instructions
Writing to the console
To write messages to the Firebug console:
- In the lower right corner of Firefox, click the Firebug button to start Firebug.
- Click the tab to view the Console tab.
- Place your cursor on the command line (shown below) and type one of the console commands (described below).
- Press the Return key on your keyboard to execute the command.
Console commands
Firebug recognizes a number of commands in addition to console.log. See http://www.getfirebug.com/console.html for a complete list of commands.
console.log
Use console.log to write any message to the console. You may use either of the following formats:
console.log("Hello", postman, "!");
which displays as
Hello Newman!
or
console.log("Hello %s!", postman);
which also displays as
Hello Newman!
You can use the following characters to format your log message output:
- %s = string
- %d = integer (number formatting not yet supported in Firebug)
- %i = integer
- %f = floating point number (number formatting not yet supported in Firebug)
- %o = object hyperlink
See http://www.getfirebug.com/console.html for a full list of console API commands for Firebug.