Reputation: 5509
I am unable to get a lot of referral URLS using document.referrer. I'm not sure what is going on. I would appreciate it if anyone had any info on its limitations (like which browser does not support what) etc.
Is there something else i could use (in a different language perhaps) that covers more browsers etc?
Upvotes: 1
Views: 2159
Reputation: 2087
The document.referrer
will be an empty string if:
rel="noreferrer"
;Check out https://developer.mozilla.org/en-US/docs/Web/API/Document/referrer
Upvotes: 0
Reputation: 91
Which browser are you looking in? If the referring website is sending the traffic via window.open('some link')
instead of a regular <a>
tag, then IE will not see a referrer. It thinks it's a new request at that point, similar to you simply going to a URL directly (in which case there is no referrer). Firefox and Chrome do not have the same issue.
This is NOT just a javascript limitation, HTTP_REFERRER
will NOT work either in this specific scenario.
Upvotes: 1
Reputation: 9159
Just to make sure you're on the same page, you do know that if someone types a URL directly in their web browser, the document.referrer property is empty, right? That being said, you might be interested in a JavScript method to get all HTTP headers. If you prefer PHP (since you're using that tag), the standard $_SERVER variable will provide what information is available. Note that the information is only as reliable as the reporting web browser and server, as noted by Kev.
Upvotes: 0
Reputation: 119856
I wouldn't put any faith in document.referrer
in your Javascript code. The value is sent in client side request headers (Referer
) and as such it can be spoofed and manipulated.
For more info see my answer to this question about the server side HTTP_REFERER
server variable:
Upvotes: 1