[Project_owners] Opening a new browser tab from a siebar application

Neil neil at parkwaycc.co.uk
Tue Jul 6 01:02:07 EDT 2004


Scott McWhirter wrote:

> Currently writing a little sidebar application but am having 
> difficulty grokking the documentation in terms of this. I know i need 
> to get a reference to the currently running browser window, which i've 
> got, but there doesn't seem to be any sort of sane interface to load a 
> uri in a new tab. Here's what i've got at the moment:
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------- 
>
> var windowmanager = 
> Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator); 
>
> var browser = windowmanager.getMostRecentWindow('navigator:browser');
>
> // open link in new tab
> var url = 'http://kungfuftr.com/code/mozilla';
> var tab = browser.parent.newTab(url);
> ----------------------------------------------------------------------------------------------------------------------------------------------------- 
>
> If anyone has any suggestions, I'd be extremely grateful.

If your sidebar is installed as chrome then iirc you can just use "top" 
to refer to the browser window, e.g. top.getBrowser().addTab(url);


More information about the Project_owners mailing list