[Jslib] XPCOM Helpers....

Daniel Aquino mr.danielaquino at gmail.com
Tue Mar 27 13:08:38 PST 2007


Well for one thing "window.open" and "window.openDialog".

To perform those actions from a XPCOM Component you need to do something
like:

-----------------------


     supports_array = function( refArray ){
       array = Components.classes["@mozilla.org/supports-array;1"]
                                        .createInstance(
Components.interfaces.nsISupportsArray);
       for( var x = 0; x < refArray.length; x++ )
           array.AppendElement( refArray[x] );
       return array;
     }

window_open = function( refParent, strUrl, strWindowName, strWindowFeatures,
refArray ){
       return Components.classes["@mozilla.org/embedcomp/window-watcher;1 "]
                .getService(Components.interfaces.nsIWindowWatcher)
                .openWindow( refParent, strUrl, strWindowName,
strWindowFeatures, supports_array(refArray) );
}


---------------

(I quickly shortened my code to the result above ... that code will probably
not work its just an example)

As you can see when your in a xpcom component none of the api's your use to
inside of a window are easy to replicate...

And in reality I still haven't successfully passed arguments to the new
window using code like the example above...

It would be really nice if there was a jslib for xpcom components to replace
the missing features that exist inside of the window scope...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/jslib/attachments/20070327/7fcf2677/attachment.html 


More information about the Jslib mailing list