[Jslib] Using Jslib from other Xpcom Components

Pete Collins pete at mozdevgroup.com
Thu Mar 15 12:51:10 PST 2007



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



More information about the Jslib mailing list