I am trying to take a snapshot of all tabs in Firefox, but am having
problems working out how to access the URIs of all the pages.
So far, I have managed to get the labels of all the tabs:
var tabs=gBrowser.tabContainer.childNodes;
for(var i=tabs.length - 1; i>=0; i--)
{
alert(tabs[i].getAttribute('label'));
}
How do I get the URIs? Elements of type tab inherit the uri attribute
from the XUL element, but it just comes up blank.
Cheers
M
--
Matthew Smith
IT Consultancy & Accessible Web Application Development
Business: http://www.kbc.net.au/
Personal: http://www.smiffysplace.com/
LinkedIn: http://www.linkedin.com/in/smiffy
>I am trying to take a snapshot of all tabs in Firefox, but am having problems working out how to access the URIs of all the pages.
>
>
You should look at the way the "Bookmark this group of tabs" code works
(sorry I don't have a link).
--
Warning: May contain traces of nuts.
I was unable to find it in the browser source, although found a few
clues which, with DOM inspector got the answer:
// Get browsers object
var browsers=document.getElementById('content').browsers;
var numBrowsers=browsers.length;
for (var i=0; numBrowsers>i; i++)
{
var thisURI=browsers[i].currentURI.spec;
// do something with it.
>// Get browsers object
>var browsers=document.getElementById('content').browsers;
>var numBrowsers=browsers.length;
>
> for (var i=0; numBrowsers>i; i++)
> {
> var thisURI=browsers[i].currentURI.spec;
> // do something with it.
> }
>
>
You can get the titles too using .contentTitle which would save you a step.
In this instance, I just need the URIs. This is a new part of my
WebSticky[1] project, similar to "bookmark group of tabs". We retrieve
the URIs of all open tabs, turn them into an XML string, then POST it to
the server. We can then reverse the process to restore the snapshot.
As this is a client/server model, one can snapshot the tabs on one
computer (say work), then restore them on another computer (say home).
Cheers
M