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

  1.  
  2.  
  3. const REF_URI = Components.Constructor("@mozilla.org/network/standard-url;1", "nsIURI");
  4. var REF = new REF_URI;
  5. REF.spec = 'http://gadelkareem.com/';
  6.  
  7. function LoadURL(url, openTab)
  8. {
  9.         if(openTab)
  10.         {
  11.         var newTab = getBrowser().addTab(url, REF, null, null);
  12.         getBrowser().selectedTab = newTab;
  13.         }
  14.         else
  15.         {
  16.                 getBrowser().webNavigation.loadURI(url, Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE, REF, null, null);
  17.         }
  18.        
  19. }
  20.  
  21.  

Tags :

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.

 

Leave a Reply


 Top