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 anhttps
site to anhttp
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
1 Answer
Reset to default 4There 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
评论列表(0条)