Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7092381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:18:23+00:00 2026-05-28T08:18:23+00:00

Normally, the referrer is traceable through: JavaScript’s document.referrer The request headers, e.g. PHP’s $_SERVER[‘HTTP_REFERER’]

  • 0

Normally, the referrer is traceable through:

  • JavaScript’s document.referrer
  • The request headers, e.g. PHP’s $_SERVER['HTTP_REFERER']

I have set up a Codepad demo which shows these properties, for testing purposes.

#Requirements:

  1. The original referrer should effectively be hidden, at least for all mouse events.
  2. Cross-browser support (at least Chrome and Firefox).
  3. Stand-alone, without any external content (plugins, libraries, redirection pages, …).
  4. No side-effects: Links should not be rewritten, history entries should be preserved.

The solution will be used to hide the referrer when following a link of <a href="url">.


##Exact description of the use-case
As described in this question on Webapps, links at Google Search are modified on click. Consequently,

  1. Google is able to track your search behaviour (Privacy– )
  2. The page request is slightly delayed.
  3. The linked page cannot track your Google search query (Privacy++ )
  4. Dragged/Copied URLs look like http://google.com/lotsoftrash?url=actualurl.

I’m developing a Userscript (Firefox) / Content script (Chrome) (code), which removes Google’s link-mutilating event. As a result, points 1, 2 and 4 are dealt with.

Point 3 remains.

  • Chrome: <a rel="noreferrer">
  • Firefox: data-URIs. I have created a sophisticated approach to implement this feature for left- and middle-clicks, while still enforcing point 4. However, I’m struggling with the right-click method.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:18:24+00:00Added an answer on May 28, 2026 at 8:18 am

    I have found a solution which works in Chrome and Firefox. I’ve implemented the code in a Userscript, Don’t track me Google.

    Demo (tested in Firefox 9 and Chrome 17): http://jsfiddle.net/RxHw5/

    Referrer hiding for Webkit (Chrome, ..) and Firefox 37+ (33+*)

    Webkit-based browsers (such as Chrome, Safari) support <a rel="noreferrer">spec.
    Referrer hiding can fully be implemented by combining this method with two event listeners:

    • mousedown – On click, middle-click, right-click contextmenu, …
    • keydown (Tab Tab Tab … Enter).

    Code:

    function hideRefer(e) {
       var a = e.target;
       // The following line is used to deal with nested elements,
       //  such as: <a href="."> Stack <em>Overflow</em> </a>.
       if (a && a.tagName !== 'A') a = a.parentNode;
       if (a && a.tagName === 'A') {
          a.rel = 'noreferrer';
       }
    }
    window.addEventListener('mousedown', hideRefer, true);
    window.addEventListener('keydown', hideRefer, true);
    

    * rel=noreferrer is supported in Firefox since 33, but support was limited to in-page links. Referrers were still sent when the user opened the tab via the context menu. This bug was fixed in Firefox 37 [bug 1031264].

    Referrer hiding for old Firefox versions

    Firefox did not support rel="noreferrer" until version 33 `[bug 530396] (or 37, if you wish to hide the referrer for context menus as well).

    A data-URI + <meta http-equiv=refresh> can be used to hide the referrer in Firefox (and IE). Implementing this feature is more complicated, but also requires two events:

    • click – On click, on middle-click, Enter
    • contextmenu – On right-click, Tab Tab … Contextmenu

    In Firefox, the click event is fired for each mouseup and hitting Enter on a link (or form control). The contextmenu event is required, because the click event fires too late for this case.

    Based on data-URIs and split-second time-outs:
    When the click event is triggered, the href attribute is temporarily replaced with a data-URI. The event finished, and the default behaviour occurs: Opening the data-URI, dependent on the target attribute and SHIFT/CTRL modifiers.
    Meanwhile, the href attribute is restored to its original state.

    When the contextmenu event is triggered, the link also changes for a split second.

    • The Open Link in ... options will open the data-URI.
    • The Copy Link location option refers to the restored, original URI.
    • ☹ The Bookmark option refers to the data-URI.
    • ☹ Save Link as points to the data-URI.

    Code:

    // Create a data-URI, redirection by <meta http-equiv=refresh content="0;url=..">
    function doNotTrack(url) {
       // As short as possible. " can potentially break the <meta content> attribute,
       // # breaks the data-URI. So, escape both characters.
       var url = url.replace(/"/g,'%22').replace(/#/g,'%23');
       // In case the server does not respond, or if one wants to bookmark the page,
       //  also include an anchor. Strictly, only <meta ... > is needed.
       url = '<title>Redirect</title>'
           + '<a href="' +url+ '" style="color:blue">' +url+ '</a>'
           + '<meta http-equiv=refresh content="0;url=' +url+ '">';
       return 'data:text/html,' + url;
    }
    function hideRefer(e) {
       var a = e.target;
       if (a && a.tagName !== 'A') a = a.parentNode;
       if (a && a.tagName === 'A') {
          if (e.type == 'contextmenu' || e.button < 2) {
             var realHref = a.href; // Remember original URI
             // Replaces href attribute with data-URI
             a.href = doNotTrack(a.href);
             // Restore the URI, as soon as possible
             setTimeout(function() {a.href = realHref;}, 4);
          }
       }
    }
    document.addEventListener('click', hideRefer, true);
    document.addEventListener('contextmenu', hideRefer, true);
    

    Combining both methods

    Unfortunately, there is no straightforward way to feature-detect this feature (let alone account for bugs). So you can either select the relevant code based on navigator.userAgent (i.e. UA-sniffing), or use one of the convoluted detection methods from How can I detect rel="noreferrer" support?.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Normally I create web application projects and use code-behind, but I have a requirement
Normally I would us <form target=_blank> But looking through http://www.w3schools.com/tags/tag_form.asp I notice the target
I have a windows form application which needs to be the TopMost. I've set
Normally when I implement a singleton I make the instance dynamic and have a
Normally when you iterate through a mysql result you do something like this: while
Normally you would have a single ErrorProvider for all the controls on a form;
Normally one would build a related model instance through its parent object: @child =
I have a only one .php ( root/process.php ) file for multiple languages root/en/command.htm
Normally when you add a new assembly you have to go into Visual Studio
Normally when I want to run a php script from the command line I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.