Topics

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

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close