[Project_owners] Calling JS functions in browser windows from dialogs

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


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:

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.
>>>>        
>>>>



More information about the Project_owners mailing list