tags:

views:

14

answers:

1

Hi, I'm training to get the address of all open tabs in firefox with no success. My problem is to open a tab if there's no already open, so I should search an address into tabs, and if there isn't, add one.

Thanks

+1  A: 

You have to iterate over all tabs, get the URLs and compare them. You can get the tabbrowser element via the global variable gBrowser.
It has a property browsers which is a NodeList of browser elements.
You can get the document object of each webpage via browser.contentDocument and then you can get the location object, which is the URL.

So you just have to iterate over the browsers node list and extract the URL from the location objects.

You can add a new tab via gBrowser.addTab().

This might be also worth reading: Tabbed browser.

Felix Kling
great! now works "var debug = "items: "+ gBrowser.browsers.length; for (var i = 0; i < gBrowser.browsers.length; ++i) { debug+= gBrowser.browsers[i].contentDocument.domain; // }"