I have an addon that open a html page when you click a button on the browser bar (so far so good) in the html page I have this javascript:
function new_version_show_window()
{
if (prefManager.getCharPref("extensions.mf_unblocker.blocker_version_in_prefs") != this_version)
{
gBrowser.selectedTab = gBrowser.addTab("http://mfre.com/mf/new_install_'+this_version+'.html");
}
}
But I am getting the error:
gBrowser is undefined
The javascript is in
chrome://mf_unblocker/content/0_register.html
so I am very much still in the browser extension how do i get it to open a new tab?
Thanks!
Ryan
Try this:
var win = Components.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator)
.getMostRecentWindow('navigator:browser');
win.gBrowser.selectedTab = win.gBrowser.addTab(url);
Assuming url is the URL to be opened
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With