Open main menu

CDOT Wiki β

Changes

Mozilla.dev.tech.xul

1,526 bytes added, 19:21, 1 December 2006
FAQ
:*/
:</pre>
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/55136a31f12497cc/22e2b0dadf941259#22e2b0dadf941259 How do I create XUL elements dynamically in JavaScript?] ===
 
Use the following snippet of code to add a new element under an existing element:
var elem = document.getElementById(XUL_ELEMENT_ID);
var node = document.createElement(XUL_ELEMENT_NAME);
node.setAttribute(ATTRIBUTE, VALUE);
node.setAttribute(ATTRIBUTE, VALUE);
elem.appendChild(node);
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/df9104b140a1961b/8aa034e25417bc55#8aa034e25417bc55 How do I access XUL elements in a sidebar from the context menu JavaScript?] ===
 
The sidebar's content is a separate document, so you should use document.getElementById("sidebar").contentDocument.getElementById(...)
 
This is something you could see using the DOMi.
 
See also http://developer.mozilla.org/en/docs/Working_with_windows_in_chrome_code
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/6098538f09e9822c/3e1ff364f7a986d5#3e1ff364f7a986d5 How can I include a .js document from inside a JavaScript document?] ===
 
Use the following snippet of code to reference a js file within a js file:
objScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
objScriptLoader.loadSubScript(strURL);
 
See http://www.xulplanet.com/references/xpcomref/ifaces/mozIJSSubScriptLoader.html for more information.
== UnAnswered Questions (UAQ) ==
1
edit