Search code examples
javascriptfirefoxfirefox-addondom-eventsxul

How to create a new tab in the Firefox extension and get the elements of the tab


I want to create a new Firefox extension where the new tab elements can be accessed specially the popup.

var win = Components.classes['@mozilla.org/appshell/window-mediator;1']
              .getService(Components.interfaces.nsIWindowMediator)
              .getMostRecentWindow('navigator:browser');
               var a = win.gBrowser.selectedTab;

I want to access all the elements which remains open or will open in the new tab in the new tab; basically I want to know how to access the elements in the new tab.


Solution

  • Do you mean that you want to access the DOM of the page in the tab? If so you can use:

    var doc = win.getBrowser.contentDocument;