0

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 Answer 1

6

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.

1
  • great! now works "var debug = "items: "+ gBrowser.browsers.length; for (var i = 0; i < gBrowser.browsers.length; ++i) { debug+= gBrowser.browsers[i].contentDocument.domain; // } "
    – LXG
    Oct 2, 2010 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.