Sudhakar Chandra aber hob zu reden an und schrieb:
> However, my problem is that I want my application to run both inside
> Firefox and Mozilla. How do I conditionally include
> chrome://browser/.../bookmarks.js for FF and
> chrome://communicator/.../bookmarks.js for Mozilla?
> 
> Is there a more elegant way of doing this than a conditional (if()) with
> document.write("<script...")?

You can use the mozIJSSubScriptLoader interface:

const ksCID_LoadJSService = "@mozilla.org/moz/jssubscript-loader;1";
var oLoader = Components.classes[ksCID_LoadJSService]
            .getService(Components.interfaces.mozIJSSubScriptLoader);
oLoader.loadSubScript(sURL, oContext);

oContext is the JS context the script will be loaded into, eg. |this| or
an object:

oLoader.loadSubScript(asURL, this);

loads into the current window (or object if inside a member function),

var o = {};
oLoader.loadSubScript(sURL, o);

makes the a |function xxx() {...}| in the file sURL be accessible via
|o.xxx();|


HTH,

Karsten
-- 
Feel free to correct my English. :)
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners

Reply via email to