I'm trying to allow the user to open a tab either in the foreground (i.e., add a tab and make it active) or in the background by ctrl+clicking or ctrl+shift+clicking, respectively, the toolbar icon of my add-on. With either of these methods, I want to wait for the tab to load, and then do some further changes.
Now to do it when the tab is to be opened in the background, I found the code here: https://developer.mozilla.org/en-US/Add ... ed_browser, under the heading 'Manipulating content of a new tab'. I'm copying it here:
Code: Select all
var newTabBrowser = gBrowser.getBrowserForTab(gBrowser.addTab("http://www.google.com/"));
newTabBrowser.addEventListener("load", function () {
newTabBrowser.contentDocument.body.innerHTML = "<div>hello world</div>";
}, true);
Code: Select all
gBrowser.selectedTab = gBrowser.addTab("http://www.google.com/");
Thanks.