XUL: How do I open an URL?
Developing extensions to work in both Mozilla 1.x, Mozilla Firefox and Mozilla Thunderbird isn't easy. Sometimes it seems that instead of developing some common JavaScript functions that can be used in both Mozilla Firefox and Mozilla Thunderbird, which uses the same toolkit, new functions are developed.
So my simple questions is this:
How do I open a new window with an URL from within a XUL window?
My demands are:
- The context is XUL. We're not talking webpage JavaScript.
- The function has to work in both Mozilla 1.x, Mozilla Firefox and Mozilla Thunderbird.
- If an URL is opened from within Mozilla 1.x it has to use Mozilla 1.x for the URL not the default browser.
- It must open a new window, not reuse an existing one.
Mozilla Thunderbird seems to do something like this:
var messenger = Components.classes["@mozilla.org/messenger;1"].createInstance();
messenger = messenger.QueryInterface(Components.interfaces.nsIMessenger);
messenger.launchExternalURL(aURL);
In Mozilla Firefox you can do:
document.commandDispatcher.focusedWindow.open(aURL)
Sometimes it's also done like this:
window.opener.openURL(aURL)
In Mozilla 1.x it seems you can do both of the above. This is because Mozilla 1.x also has a "messenger" component.
document.commandDispatcher.focusedWindow.openURL(aURL)
But could someone please write a function that works in both Mozilla 1.x, Mozilla Firefox and Mozilla Thunderbird?
Why isn't there a standard function for stuff like this or have I missed it?
Ads:
3 Comments
Probably I don't understand very well the question, but why don't use a simple window.open ?
Eg:
window.open(theURL,'','chrome,centerscreen');"
Isn't there a "loadURI" function in the global JS which opens a URL in one of the browser windows?
Gerv
Comment by Gerv at June 30, 2004 10:21 AM | Permalink
Probably I don't understand very well the question, but why don't use a simple window.open ?
Comment by Faser at June 29, 2004 05:34 PM | PermalinkEg:
window.open(theURL,'','chrome,centerscreen');"