Javascript document.referrer empty - Stack Overflow

I have been searching for many threads but I could not find the solution. I would like to get document.

I have been searching for many threads but I could not find the solution. I would like to get document.referrer but it always show empty. Its been so confusing. Here is my code

<script>
alert(document.referrer);
</script>

I got that code from w3schools. However, it is not work from my side. I have tried the code there and it works fine but not for mine.

I have an analysis that it is because my domain is under CloudFlare. Everyone knows that CloudFlare uses Proxy to redirect users before they go to our site but I would like to ask your opinion here. If it is not possible, is there any way I can do to pass http referrer? Thank you.

I have been searching for many threads but I could not find the solution. I would like to get document.referrer but it always show empty. Its been so confusing. Here is my code

<script>
alert(document.referrer);
</script>

I got that code from w3schools. However, it is not work from my side. I have tried the code there and it works fine but not for mine.

I have an analysis that it is because my domain is under CloudFlare. Everyone knows that CloudFlare uses Proxy to redirect users before they go to our site but I would like to ask your opinion here. If it is not possible, is there any way I can do to pass http referrer? Thank you.

Share Improve this question asked Oct 29, 2017 at 16:46 Drake BoeinDrake Boein 1171 silver badge11 bronze badges 2
  • 1 document.referrer is empty if you navigate from an https site to an http one, though even if I navigate from here to MDN it’s an empty string… – Sebastian Simon Commented Oct 29, 2017 at 16:54
  • is there any way I can do to retrieve it? – Drake Boein Commented Oct 29, 2017 at 16:57
Add a ment  | 

1 Answer 1

Reset to default 4

There is no way to retrieve the referral data if the host has set Referrer-Policy: no-referrer in their HTTP Header.

Since Cloudflare works as a reverse proxy it's not possible to get referral data in the same way as usual. You can read more here

Maybe Cloudflare keeps the data in your control panel, or you could find the correct data with tools like Google Analytics.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745200832a4616313.html

相关推荐

  • Javascript document.referrer empty - Stack Overflow

    I have been searching for many threads but I could not find the solution. I would like to get document.

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信