Reputation: 8127
I need to do a Javascript based redirect
window.location.href = 'URL';
But I need to remove the referrer from the HTTP headers upon redirection (the target page should see no referrer), how can I do that?
Upvotes: 6
Views: 12202
Reputation: 76
I know that this question has been inactive for a while, found it browsing the web and found a nice answer that may help save another person's time. This version uses JQuery.
$(function(){
$("#button").on("click", function(){
$("head").append('<meta name="referrer" content="no-referrer"/>');
window.location = "http://www.example.org";
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="button">Click to navigate</button>
Upvotes: 0
Reputation: 72
<a href="redirecturl" rel="noreferrer" id="autoclick">Link</a>
<script>document.getElementById('autoclick').click();</script>
Upvotes: 5
Reputation: 2742
If you only going to do this for location redirect, then you can set up a bridge page hosted somewhere less sensitive and doesn't do anything other than redirect. Now you can link all the destination to http://<redirect_page>?<actual_url>
window.location.href= window.location.href.split("?")[1];
Upvotes: 0
Reputation:
There is but as far as I know it's not beautiful. Check the first answer here
Upvotes: 1
Reputation: 41958
You can't. It's up to the browser to set referrer headers or not, the script has no influence on it.
Upvotes: -2