Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

Questions and answers from the newsgroups 2006 12 01

Return to mozilla-dev-extensions


FAQ

(↑ top)

HI want to change the XUL user-interface at run-time, and save the modified user-interface into a XUL file to be prepared for reusing. How can I do this?

The only way of "saving" XUL is to serialize the modified DOM using XMLSerializer. Here are some links you can check out about the XMLSerializer:

How can i dynamically change the content type/namespace of a document?

How are you filling the the new document with the original nodes? Don't use things like appendChild(), insertBefore() because nodes shouldn't be shared between documents. You should use cloneNode(): http://developer.mozilla.org/en/docs...ment.cloneNode

I have a chrome function that I want to execute when a page has finished loading. And it works really well. The only problem is that some webpages have some onLoad JavaScript too, and I would like to run *after* they complete. Is there any way to be notified that a page has completely loaded and the onload JavaScript functions finished too?

It's possible that setting a zero-second timeout in your init() function to call another function would work, i.e.:

function init() {
  window.setTimeout(init2, 0);
}
 
function init2() {
  // Put your actual init logic here.
}

If this doesn't work, then I don't know what would. Changing your event listener to not capture the "load" event (i.e. passing "false" as the third parameter to window.addEventListener) might work, but then the page would probably be able to stop propagating the event, preventing your listener from ever getting called.

I was just wondering if there is a way to get the HWND of the main document in firefox/mozilla?

This has been discussed before on this mailing list. Why not just use the windows API ::FindWindow() function to get Firefox's HWND?

For multi-window applications, it needs to occasionally iterate over each of the application windows and do something to my add-on's UI. I have cobbled something together that works fine. But it seems that the application must know of its open windows. Is there any way for my add-on to get access to this information?

Use the window mediator to iterate over open windows. For example:

var mediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]. 
    getService(Components.interfaces.nsIWindowMediator);
 
// Grab browser windows; for all windows, pass null as the parameter.
var windows = mediator.getEnumerator("navigator:browser");
 
while (windows.hasMoreElements()) {
  var win = windows.getNext();
  // Do something with the window...
} 
It would be great if tabs would go to multiple rows after having five or six tabs up and set colors for different tabs or rows just to help sort things out. Is that possible?

There are are a few possibilities for colours:

ColorfulTabs which gives each tab a different colour based on domain or random color. It has options to differentiate the background tabs by hilighting the selected tab: http://varun21.googlepages.com/firefox.html https://addons.mozilla.org/firefox/1368/

Chromatabs which colours tabs based on host: https://addons.mozilla.org/firefox/3810/

HashColouredTabs, which I have been working on recently, which gives sites, without a site icon, a coloured icon based on the host:

[My version includes the icon in the location bar and 'list all tabs' menu]

UAQ

(↑ top)

Document Tags and Contributors

 Contributors to this page: Varun21, RichardChu
 Last updated by: Varun21,