[Project_owners] calling window.sidebar.addPanel() from chrome

Philip Chee philip at aleytys.pc.my
Wed Feb 22 05:43:46 EST 2006


On Mon, 20 Feb 2006 08:47:09 +1100, David Murray wrote:

> http://www.mozdev.org/source/browse/~checkout~/deepestsender/src/content/sidebarinstall.js?rev=1.4&content-type=text/plain

Several seamonkey extensions use this code or something very similar.
Presumably they all derive from the DOM Inspector sidebar installation code.
   Where did you get this file from originally?

The problem I see is that several extensions (not deepestsender) e.g.
MozImage, load this .js file into the global (navigator.xul) scope, causing
namespace clashes. The constants declared in this file cause all but the
first file to fail to load.

One solution to this is to use mozIJSSubScriptLoader
<http://weblogs.mozillazine.org/weirdal/archives/008101.html>

To load the .js file into the context of an object:

const jsLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);

var scopeObj1 = {};
jsLoader.loadSubScript("pathtofile.js", scopeObj1);
scopeObj1.addPanel(...etc...);

By the way, is mozIJSSubScriptLoader available in Firefox 1.0.x (Gecko 1.7)?

Phil
-- 
Philip Chee <philip at aleytys.pc.my>, <philip.chee at gmail.com>
http://flashblock.mozdev.org/ http://xsidebar.mozdev.org
Guard us from the she-wolf and the wolf, and guard us from the thief,
oh Night, and so be good for us to pass.
[ ]What happens to the hole when the cheese is gone?
* TagZilla 0.059


More information about the Project_owners mailing list