最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

http headers - Remove referer from Javascript redirect - Stack Overflow

matteradmin5PV0评论

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?

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?

Share Improve this question asked May 7, 2013 at 9:52 FlavienFlavien 8,19712 gold badges50 silver badges56 bronze badges 1
  • Here is a simple trick using iframes and https: stackoverflow./a/30304058/2440 – Sire Commented May 18, 2015 at 13:19
Add a ment  | 

5 Answers 5

Reset to default 5

<a href="redirecturl" rel="noreferrer" id="autoclick">Link</a>
<script>document.getElementById('autoclick').click();</script>

There is but as far as I know it's not beautiful. Check the first answer here

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];

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";
  });
});
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button id="button">Click to navigate</button>

You can't. It's up to the browser to set referrer headers or not, the script has no influence on it.

Post a comment

comment list (0)

  1. No comments so far