List Info

Thread: Using Jslib from other Xpcom Components




Using Jslib from other Xpcom Components
user name
2007-03-15 14:19:23
Can I use jslib from my own xpcom components ?

My first attempt has shown that 'jslib' is not defined ever after 'final-ui-startup' has been observed...
Re: Using Jslib from other Xpcom Components
user name
2007-03-15 15:51:10

Daniel Aquino wrote:

> Can I use jslib from my own xpcom components ?
>
> My first attempt has shown that 'jslib' is not defined
ever after 
> 'final-ui-startup' has been observed...


Sure I do it all the time. You need to use the subscript
loader.

const CC = Components.classes;
const CI = Components.interfaces;


function initJSLib ()
{
  const jsLib =
"chrome://jslib/content/jslib.js";
  CC["mozilla.org/moz/jssubscript-loader;1"].
   
getService(CI.mozIJSSubScriptLoader).loadSubScript(jsLib);

  JS_LIB_DEBUG = JS_LIB_ON;
  jslibTurnDumpOn();
  jslibTurnStrictOn();
}


Then just call this func from somewhere in your component to
initialize it.

initJSLib();

--pete

-- 
Pete Collins - Founder, Mozdev Group Inc.
www.mozdevgroup.com
Mozilla Software Development Solutions
tel: 1-719-302-5811
fax: 1-719-302-5813

_______________________________________________
Jslib mailing list
Jslibmozdev.org
http://mozde
v.org/mailman/listinfo/jslib

Re: Using Jslib from other Xpcom Components
user name
2007-03-15 15:04:37
I tried to use the following code to load jslib from my component:

         ;       try {
       ;           var jslib = Components.classes["mozilla.org/jslib;1"]
      ;           ;           ;           ; .createInstance(Components.interfaces.mozIJSLib);
          ;      } catch (anError) {
       ;           dump(";t ERROR: " + anError + "n");
 ;           ;    }

But I got the error:

-*- jsLib component: Not an nsIDOMChromeWindow

You can clearly see that the error is originating from the jsLib.prototype.init...

But from looking at how the constructor behaives,
I fear jslib is very tied to being in a window context...



Re: Using Jslib from other Xpcom Components
user name
2007-03-15 17:45:54
awesome thanks!
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )