There are two situations in which you would want to control the Referer header. By the way, Referer is a miss-spelling of the word "referrer". If you want to control your personal browser not to pass the Referer to site2.com, you can do that with many browser extensions: For Firefox there is RefControl (which I use and am happy with.
On the web browser menu click on the "Edit" and select "Preferences". In the "Preferences" window select the "Security" tab. In the "Security" tab section "Web content" mark the "Enable JavaScript" checkbox. Click on the "Reload the current page" button of the web browser to refresh the page. The JavaScript Source: User Details: Referrer. Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!! HTTP referrer using Javascript This is another simple script to get the HTTP referrer using javascript. It will help you in getting the referrer, The page from which your current web page got loaded. Use JavaScript’s referrer property to find out where your visitor came from. If you want to access referrer and user-agent, those are available to client-side Javascript, but not by accessing the headers directly. To retrieve the referrer, use document.referrer. To access the user-agent, use navigator.userAgent.
For example document.referrer.split('/')[2] will extract the domain name. We can then locate an HTML element using getElementById and the id of the element and we can set the display attribute to either 'none' to remove the element from the DOM and make it disappear, or we can set it to 'block' to show it.
Jul 08, 2010 · No javascript or meta-based method works, in all cases resulting in an empty or internal referrer (which will misleadingly show up as bookmark/direct in most analytics packages). Interestingly, javascript and meta redirects can result in totally blank referrer data in some browsers.
Apr 27, 2020 · The referer header allows websites to see where a visitor came from. If you clicked on a link to a site from a Google search, for example, the data passed to the target site would note this. Referer header settings are great tools for webmasters, but in the age of digital privacy, they can be seen as a detriment to the end-user’s experience.
On the web browser menu click on the "Edit" and select "Preferences". In the "Preferences" window select the "Security" tab. In the "Security" tab section "Web content" mark the "Enable JavaScript" checkbox. Click on the "Reload the current page" button of the web browser to refresh the page. The JavaScript Source: User Details: Referrer. Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Apple-s). The script is yours!!! HTTP referrer using Javascript This is another simple script to get the HTTP referrer using javascript. It will help you in getting the referrer, The page from which your current web page got loaded. Use JavaScript’s referrer property to find out where your visitor came from. If you want to access referrer and user-agent, those are available to client-side Javascript, but not by accessing the headers directly. To retrieve the referrer, use document.referrer. To access the user-agent, use navigator.userAgent. The value of referrer became important as it gives information about the source of traffic to a site. Some time referrer value is used to redirect visitors to different pages based on requirement. Here is an example of code to get the referrer by using JavaScript document object.