I am trying to change the url of a currently open tab in javascript firefox extension
Any pointers please?
I am trying to change the url of a currently open tab in javascript firefox extension
Any pointers please?
The mozilla doc mentioned by TML has sample code for this under "Reusing by other criteria", but it's broken. The corresponding talk page says to add this line to fix it:
tabbrowser.loadURI(url, tabbrowser.currentURI, "UTF-8");
However, if you've already got the tab object (say from calling addTab earlier) then I think it's simpler to do:
gBrowser.selectedTab = mytab;
gBrowser.loadURI(myurl);
I don't see any way to change the URL of a tab which is NOT selected, but that would be nice - I hate stealing focus.
UPDATE: here's how you do it w/o selecting the tab. Simple:
gBrowser.getBrowserForTab(mytab).loadURI(myurl);