[Project_owners] Calling JS functions in browser windows from dialogs

Jeroen Groenenboom jagrboom at zonnet.nl
Tue Mar 28 00:59:59 EST 2006


Jeroen Groenenboom wrote:

> It seems to me that if there's no navigator window, your extension 
> (whatever it is) is probably of no use either (or just let your 
> extension fail). Although it's just an educated guess, I think this is 
> what you want:
>
> an overlay of browser.xul:
>
> <overlay id="myOverlay" 
> xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">  
>    <script type="application/x-javascript" 
> src="chrome://bookmarkshome/content/quickDialog.js"/>
>
> and in quickDialog.js:

Edit, this should be in all of your dialogs, not in quickDialog.js

>
> function myGetNavigatorWindow() {
>    return 
> Components.classes["@mozilla.org/appshell/window-mediator;1"]         
> .getService( Components.interfaces.nsIWindowMediator )
>    .getMostRecentWindow( "navigator:browser" );
> }
>
> var navigatorWindow = myGetNavigatorWindow();
>
>>>>>>> navigatorWindow.functionName()
>>>>>>>           
>>>>>>
>>>>>> This won't work if there are no navigator windows working.         
>>>>>
>>>>> Correct, and that is why I check for chrome windows first (this 
>>>>> will open a new window when needed) but what I want is in function 
>>>>> for all JS functions that I need from that chrome window.
>>>>>       
>>>>
>
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>



More information about the Project_owners mailing list