GadElKareem

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);
	}
	
}