It looks like you can do two things
A. use nsIWindowMediator interface
B. pass the window object as an arg when you are instantiating your
xpconnect wrapped object
Hope this helps
--pete
Greg Thokle wrote:
>
> Pete,
>
> My problem is that I am attempting to call a method of an object from
> XPConnect code. Below is a simple snippet of my code that attempts to
> call a method of window. Ideally I would like to call a javascript
> function in a separate javascript file that is loaded in the xul script.
>
> I have a feeling that within XPConnect, window is actually a nsI????
> interface.
>
> function rcmCallback() { }
>
> rcmCallback.prototype = {
> onContentStopped: function (activityID, returnCode) {
> window.alert("got it");
> },
>
> ************************************************************
> * Call to xpconnect wrapped JSObject produced this error: *
> [Exception... "[JavaScript Error: "window is not defined" {file:
> "D:\Mozilla\src
> \mozilla\dist\WIN32_D.OBJ\bin\components\rcmCallback.js" line: 35}]
> [IRCMCallbac
> k::onContentStopped]" nsresult: "0x80570021
> (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH
> _DETAILS)" location: "<unknown>" data: yes]
> ************************************************************
>
> Greg
>
> Pete Collins wrote:
>
> > It's hard to see what you a really doing without some code . . .
> >
> > Is this what you want?
> >
> > js> function notify(){ dump("notify\n"); }
> > js> function dummy(){ this.notifyFunction = notify; }
> > js> var d=new dummy();
> > js> d.notifyFunction();
> > notify
> > js>
> >
> > --pete