The Browser Console is like the Web Console, but applied to the whole browser rather than a single content tab.
If you also want to use the other web developer tools in the regular Web Toolbox with add-on or browser code, consider using the Browser Toolbox.
gBrowser global, and even with the XUL used to specify the browser's user interface.
devtools.chrome.enabled preference to
true in about:config, or set the 'Enable browser chrome and add-on debugging toolboxes' (Firefox 40 and later) option in the developer tool settings.
Opening the Browser Console
You can open the Browser Console in one of two ways:
- from the menu: select 'Browser Console' from the Web Developer submenu in the Firefox Menu (or Tools menu if you display the menu bar or are on macOS).
- from the keyboard: press Ctrl+Shift+J (or Cmd+Shift+J on a Mac).
You can also start the Browser Console by launching Firefox from the command line and passing the
Firefox Enable Java Linux
The Browser Console looks like this:
You can see that the Browser Console looks and behaves very much like the Web Console:
- most of the window is occupied by a pane that display messages.
- at the top, a toolbar enables you to filter the messages that appear.
Beginning with Firefox 68, the Browser Console allows you to show or hide messages from the content process (i.e. the messages from scripts in all the opened pages) by setting or clearing the checkbox labeled Show Content Messages. The following image shows the browser console focused on the same page as above after clicking on the Show Content Messages checkbox.
Browser Console logging
The Browser console logs the same sorts of messages as the Web Console:
- Input/output messages: commands send to the browser via the command line, and the result of executing them
However, it displays such messages from:
- web content hosted by all browser tabs
- the browser's own code
Messages from add-ons
The Browser Console displays messages logged by all Firefox add-ons.
To use the console API from a traditional or bootstrapped add-on, get it from the Console module.
One exported symbol from
console. Below is an example of how to access it, which adds a message to the Browser Console.
Enable Java On Firefox For Mac
There is also the HUDService which allows access to the Browse Console. The module is available at Mozilla DXR. We see we can not only access the Browser Console but also Web Console.
Here is an example on how to clear the contents of the Browser console:
If you would like to access the content document of the Browser Console this can be done with the HUDService. This example here makes it so that when you mouse over the 'Clear' button it will clear the Browser Console:
Bonus Features Available
For Add-on SDK add-ons, the console API is available automatically. Here's an example add-on that just logs an error when the user clicks a widget:
If you build this as an XPI file, then open the Browser Console, then open the XPI file in Firefox and install it, you'll see a widget labeled 'Error!' in the Add-on bar:
Click the icon. You'll see output like this in the Browser Console:
For Add-on SDK-based add-ons only, the message is prefixed with the name of the add-on ('log-error'), making it easy to find all messages from this add-on using the 'Filter output' search box. By default, only error messages are logged to the console, although you can change this in the browser's preferences.
Browser Console command line
The Browser Console command line is disabled by default. To enable it set the
devtools.chrome.enabled preference to
about:config, or set the 'Enable chrome debugging' option in the developer tool settings.
But while the Web Console executes code in the scope of the content window it's attached to, the browser console executes code in the scope of the chrome window of the browser. You can confirm this by evaluating
This means you can control the browser: opening, closing tabs and windows and changing the content that they host, and modify the browser's UI by creating, changing and removing XUL elements.
Controlling the browser
The command line interpreter gets access to the
tabbrowser object, through the
gBrowser global, and that enables you to control the browser through the command line. Try running this code in the Browser Console's command line (remember that to send multiple lines to the Browser Console, use Shift+Enter):
It adds a listener to the currently selected tab's
load event that will eat the new page, then loads a new page.
Enable Jre Firefox
Note: You can restart the browser with the command Ctrl + Alt + R (Windows, Linux) or Cmd + Alt + R (Mac) This command restarts the browser with the same tabs open as before the restart.
Modifying the browser UI
Since the global
window object is the browser's chrome window, you can also modify the browser's user interface. On Windows, the following code will add a new item to the browser's main menu:
On macOS, this similar code will add a new item to the Tools menu:
Starting in Mac OS X 10.7 (Lion), Java is not installed by default.However, when you attempt to use a program that requires Java, thesystem will automatically open and offer to install it on yourcomputer. In previous versions of Mac OS X, Java will ordinarily beinstalled by default. In any case, to make sure you have the mostrecent version of Java in Mac OS X, use Software Update;see ARCHIVED: For Mac OS X, how do I obtain and install system softwareupdates?
All current web browsers, including Safari,Firefox, and Chrome, support Java.
- Enabling or disabling Java in your browser
Enable Java Firefox 69
Enabling or disabling Java in your browser
- From the Safari menu, select Preferences....
- At the top of the resulting window, click the Security icon.
- Check or uncheck the Enable Java box.
- From the Tools menu, click Add-ons.
- In the left column, select Plugins.
- Click Java Applet plug-ins, and then, on the right, click Enable or Disable.
- From the Chrome menu, select Preferences....
- In the left column, click Settings.
- At the bottom of the window, select Show advancedsettings....
- In the 'Privacy' section, click Content settings....
- In the 'Plug-ins' section of the
Content settingswindow, click Disable individual plugins....
- Find the entry for Java and click Enable or Disable.
Enabling or disabling Java for all systems on your Mac
Enable Java Plugin Firefox
- Open the Applications folder, and then the Utilities folder.
- Double-click Java Preferences.
- Select the General tab and check or uncheck all options.