Getting the gBrowser object in Firefox

Okies finally I have succumb and decided to do a Firefox add-on or extension to save open tabs that have documents/images inside, cause I am lazy to go one by one and save them.

So first step, try and get the tab browsers elements in the browser. In Firefox, there is a gBrowser object that if you can get it will help you to get all the browser tabs and their uris.

For the documentation, the only way that you can use gBrowser directly is that if you are under the scope of browser.xul when you are doing overlays. So for other windows like dialogs and sidebars, you will need to use window.opener.getBrowser method to get to the gBrowser object. If you look at the documentation for the window object, there is no mention of the getBrowser method, seems like the docs need some updating.

Look at the Getting access to the browser in the Tabbed Browser section of the MDC, you will find the various different methods for getting a gBrowser object.

About these ads
Explore posts in the same categories: Programming

Tags:

You can comment below, or link to this permanent URL from your own site.

2 Comments on “Getting the gBrowser object in Firefox”

  1. Andriy Humenetskyy Says:

    I had problem “gBrowser is not defined” when tried access to gBrowser from sidebar.
    Solution:
    var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
    .getInterface(Components.interfaces.nsIWebNavigation)
    .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
    .rootTreeItem
    .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
    .getInterface(Components.interfaces.nsIDOMWindow);
    var gBrowser = mainWindow.gBrowser;


  2. […] Getting the gBrowser object in Firefox August 2009 1 comment Possibly related posts: (automatically generated)#1 Page and Top 3 Posts In 2009 Explore posts in the same categories: Uncategorized […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: