Changes

Jump to: navigation, search

Mozilla.dev.tech.xul

8,284 bytes added, 20:21, 1 December 2006
FAQ
# [http://developer.mozilla.org/en/docs/Newsgroup_summaries:mozilla-dev-tech-xul:2006-11-03 Friday November 3, 2006]
# [http://developer.mozilla.org/en/docs/Newsgroup_summaries:mozilla-dev-tech-xul:2006-11-10 Friday November 10, 2006]
# [http://developer.mozilla.org/en/docs/Newsgroup_summaries:mozilla-dev-tech-xul:2006-11-17 Friday November 17, 2006]
# [http://developer.mozilla.org/en/docs/Newsgroup_summaries:mozilla-dev-tech-xul:2006-11-24 Friday November 24, 2006]
# [http://developer.mozilla.org/en/docs/Newsgroup_summaries:mozilla-dev-tech-xul:2006-12-01 Friday December 1, 2006]
== FAQ ==
:electedtreeitem.firstChild.setAttribute('style', 'background: #FF0000');
:</pre>
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/1c47b84ce54353a5/9daa474a70c5dff6#9daa474a70c5dff6 Specifying window.onload function] ===
 
To specify a function to run when the window is loaded,add the following code between the script tags in the XUL file:
window.addEventListener("load", function(e) { startup(); }, false);
 
Similarly, for onunload use the code:
window.addEventListener("unload", function(e) { shutdown(); }, false);
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/f0aa44a69e64dda5/b86f0e12f5941092#b86f0e12f5941092 Is there an event which is called when the Firefox browser is initialized?] ===
 
An event is initiated when the application starts up and when the profile is changed. For more information please look at the following link: [http://lxr.mozilla.org/mozilla/source/toolkit/mozapps/extensions/src/nsExtensionManager.js.in#2703 nsExtensionManager.js]
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/40b79fb4574cac8b/5c46a2cebfcae898#5c46a2cebfcae898 Is nsIVariant fully supported using python?] ===
 
Python has full support for variants. Pass a Python string/int/etc to the method requiring an nsIVariant. A Python object is convered when implmenting an interface taking an nsIVariant.
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/b8916415bc0fa019/9c7fd67b21949317#9c7fd67b21949317 How do I close the "showPopup" which is automatically opened when the "oncontextmenu" event is called?] ===
 
If you have a similar code base as the following:
 
:<pre>
:onBookmarkContextMenu: function(event, id) {
: document.getElementById("bookmarkPopup").showPopup(document.getElementById(id),
: event.screenX + 6, event.screenY + 6, "popup", "bottomright",
: "bottomright");
:
:}
:</pre>
 
Use the hidePopup() function to solve this issue.
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/9bf54cc3afe1c340/100724af248a02ad#100724af248a02ad What is an example of addProgressListener?] ===
 
An example of this is this:
 
:<pre>
:// Associate the progress listener for a "browser" to a listener object
:
:browserObject.addProgressListener( listObj,
: Components.interfaces.nsIWebProgress.NOTIFY_STATE_WINDOW );
:
:// Remember to define the object, something like this:
:
:listObj = new Object();
:
:listObj.wpl = Components.interfaces.nsIWebProgressListener;
:
:listObj.QueryInterface = function(aIID) {
: if (aIID.equals(listObj.wpl) ||
: aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
: aIID.equals(Components.interfaces.nsISupports)) return this;
: throw Components.results.NS_NOINTERFACE;
:
:}
:
:listObj.onStateChange = function(aProgress, aRequest, aFlag, aStatus) {
: if (aFlag & listObj.wpl.STATE_START) {
: // This fires when the load event is initiated
: } else {
: if (aFlag & listObj.wpl.STATE_STOP) {
: if ( aFlag & listObj.wpl.STATE_IS_WINDOW ) {
: // This fires when ALL load finish
: }
: if ( aFlag & listObj.wpl.STATE_IS_NETWORK ) {
: // Fires when ALL load are REALLY over,
: // do something "final" here
: // (my two cents)
: } else {
: // This fires when a load finishes
: }
: }
: }
: return 0;
:
:}
:
:// This fires when the location bar changes i.e load event is confirmed
:// or when the user switches tabs
:listObj.onLocationChange = function(aProgress, aRequest, aURI) {
:
:// do whatever you want to do
:return 0;
:
:}
:
:// For definitions of the remaining functions see XulPlanet.com
:listObj.onProgressChange = function() { return 0 };
:listObj.onStatusChange = function() { return 0 };
:listObj.onSecurityChange = function() { return 0 };
:listObj.onLinkIconAvailable = function() { return 0 };
:
:/*
: I use the progress listener to trap the end of a local HTML
: "template" file loading, and run XSLT transormations.
: In addition I need to evaluate the browser contentDocument DOM
: in order to clean "target" attributes on links, and so on.
:
: HTH
:*/
:</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) ==
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/c48b0997c211cb30/09fd369cfd27a782#09fd369cfd27a782 How can I center image/text within the toolbarbutton element in a xulrunner application?] ===
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/8a8e3939a2fad620/51c738063ead0511#51c738063ead0511 Issues with relative path in a jar in XUL] ===
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/010fe5746a11183e/3e59469982739735#3e59469982739735 How can I create global observers for my XUL applications?] ===
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/2354e3354d47478a/94806ab7d3a7d4c8#94806ab7d3a7d4c8 Is there a XUL function that will allow a script to determine the ID or handle of the active window task?] ===
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/b1141a8d850db281/50a5fd68808a3afc#50a5fd68808a3afc Getting an error in the console when inserting a subtree into a XUL document from another XML.] ===
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/19c4ac28a33071b3/3562fb411ad0f106#3562fb411ad0f106 Can I change the shape of the edge of the Toolbarbutton element?] ===
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/41a1096602618693/fd3527c2490338b8#fd3527c2490338b8 Custom alert window] ===
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/bc3b2322803e8178/87ca61ab171cbd55#87ca61ab171cbd55 Updating observes attribute] ===
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/62f0d1fb0ed52543/77ee30fd2fef45e6#77ee30fd2fef45e6 Hover Help on Dynamically Generated XUL Elements] ===
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/842dfac328743b80/f8eb7fb268354c80#f8eb7fb268354c80 Is there an example of scrollingrows.xul from the firefox source?] ===
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/a1246bb44631f0d0/9389e7e2cb624055#9389e7e2cb624055 How do I make my XULRunner application run in front of all my applications on OSX?] ===
 
=== [http://groups.google.com/group/mozilla.dev.tech.xul/browse_thread/thread/73930957246a9c93/a9a335c545b1934a#a9a335c545b1934a Toolbar and side bar syntax problem] ===
1
edit

Navigation menu