You can use document referrer for this.
document.referrer
https://developer.mozilla.org/en-US/docs/Web/API/document.referrer
Domanda
Can a jquery or javascript pick up inbound links on a page? For example, I need to determine whether a page was a) reloaded b) entered from a foreign link or c) clicked on by a link within my domain name
Soluzione
You can use document referrer for this.
document.referrer
https://developer.mozilla.org/en-US/docs/Web/API/document.referrer
Altri suggerimenti
document.referrer
will tell you the URL of the page that the user came from, or will be empty on Refresh.
But I wouldn't base any security-sensitive code on it - the equivalent Referer
(sic) HTTP header is easy to spoof, and I suspect document.referrer
is too.
Look at the referrer headers - found in document.referrer This will tell you details of where the link has come from.
Yes and no. The CGI might be available to you depending on your platform, which you may be able to systematically make available to js.
However, you can also try this: console.log(document.referrer);
I don't think there is a systematic way to check a 'reload'. But by comparing document.referrer
with location.hostname
or other properties of location
, you can determine foreign/internal clicks/links. A reload would perhaps be determined by having the same internal referrer as the current page (and queryString values).