Change url of javascript firefox tab

I am trying to change the url of the currently open tab in the javascript firefox extension

Any pointers please?

+1


a source to share


2 answers


I believe it is "gbrowser.loadURI ()". Try reading this page on MDC about interacting with the global variable gBrowser and here about the loadURI method.



+5


a source


The mozilla doc mentioned by TML has sample code for this in the section "Reuse by different criteria", but it's broken. The related page says to add this line to fix it:

tabbrowser.loadURI(url, tabbrowser.currentURI, "UTF-8");

      

However, if you already have a tab object (say from the addTab call earlier), then I think it's easier:

gBrowser.selectedTab = mytab;
gBrowser.loadURI(myurl);

      



I don't see any way to change the url of a tab that is NOT selected, but that would be nice - I hate focus stealing.

UPDATE: here's how you do it, no tab selection. Plain:

gBrowser.getBrowserForTab(mytab).loadURI(myurl);

      

+2


a source







All Articles