Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Get URL from addTab - XUL object

21 views
Skip to first unread message

bann...@gmail.com

unread,
Nov 7, 2006, 4:51:06 PM11/7/06
to
Hi,

I need to get the url from a tab I added through:

var url = "myurl.htm";
var myTab = getBrowser().addTab(url);

I've successfully used content.location on Chrome elements, but can't
find the resource that will point me towards the same from the XUL
object returned by addTab.

Thanks in advance!

Eric H. Jung

unread,
Nov 7, 2006, 6:06:34 PM11/7/06
to dev-extensions
You should wait for the tab to load before getting its URL; otherwise, your code won't account for redirects.

Hi,

Thanks in advance!

_______________________________________________
dev-extensions mailing list
dev-ext...@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-extensions

Eric H. Jung

unread,
Nov 7, 2006, 6:48:15 PM11/7/06
to rob rhyne, dev-extensions
Rob,

cc'ing the list...looks like you forgot. There's more than one way to do this. Assuming you know the index of the tab:

getBrowser().getBrowserAtIndex(0).currentURI.spec

see also: http://kb.mozillazine.org/Getting_Current_URL

-Eric


----- Original Message ----

From: rob rhyne <r...@biglike.com>

To: Eric H. Jung <eric...@yahoo.com>

Sent: Tuesday, November 7, 2006 6:41:25 PM

Subject: Re: Get URL from addTab - XUL object

Eric, thanks for the reply.

Good tip Eric. I am actually waiting for the tab to load. Getting the URL will be called from another function after the page has loaded.

Can anyone point me to how to access the url from the opened tab?

r.o.b.r.h.y.n.e.

www.biglike.com

760-840-1775

r...@biglike.com

Eric H. Jung

unread,
Nov 7, 2006, 7:11:31 PM11/7/06
to dev-extensions

rob rhyne

unread,
Nov 7, 2006, 7:51:42 PM11/7/06
to Eric H. Jung, dev-extensions
Eric,

That's just the push I needed.

I got the index of my added tab...

tabIndex = gBrowser.mTabContainer.selectedIndex;

Then retrieved my tab with:

var myTabUrl = getBrowser().getBrowserAtIndex
(tabIndex).currentURI.spec;

Thanks a ton!

Neil

unread,
Nov 8, 2006, 5:40:20 AM11/8/06
to
bann...@gmail.com wrote:

>I need to get the url from a tab I added through:
>
>var url = "myurl.htm";
>var myTab = getBrowser().addTab(url);
>
>

var myBrowser = getBrowser().getBrowserForTab(myTab);
var myURL = myBrowser.currentURI.spec;

--
Warning: May contain traces of nuts.

rob rhyne

unread,
Nov 8, 2006, 12:32:53 PM11/8/06
to Neil, dev-ext...@lists.mozilla.org
Thanks Neil, that's even cleaner.

0 new messages