XUL : open URL with a referrer

This is a small function to use in Firefox extension development which makes use of the referrer parameter sent to loadURI() and addTab() functions

 
const REF_URI = Components.Constructor("@mozilla.org/network/standard-url;1", "nsIURI");
var REF = new REF_URI;
REF.spec = 'http://gadelkareem.com/';
 
function LoadURL(url, openTab)
{
	if(openTab)
	{
        var newTab = getBrowser().addTab(url, REF, null, null);
        getBrowser().selectedTab = newTab;
	}
	else
	{
		getBrowser().webNavigation.loadURI(url, Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE, REF, null, null);
	}
 
}

Recommended posts:


Tags : more-25

This entry was posted on Monday, December 4th, 2006 at 12:09 pm and is filed under Blog, Solutions. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


 Top