How can i get the document.referrer.refferer I mean like the referrer of the refferer of the current document.
I used the document.referrer on my site here:
function statistics() {
if(window.location.href.indexOf("statistics") > -1 && history.length) {
history.back()
} else if(window.location.href.indexOf("games") > -1 && history.length) {
window.location.replace(document.referrer + "/../tournament.html");
} else {
window.location.replace("./tournaments/tournament.html");
}
}
The purporse is to "remember" where the user has came from.
Now there is a possibility to go to a setting site from that site where this code is. Therefore the equivalent needed code would be:
function nftStatistics() {
if(window.location.href.indexOf("statistics") > -1 && history.length) {
history.go(-2)
} else if(window.location.href.indexOf("games") > -1 && history.length) {
window.location.replace(document.referrer.referrer + "/../tournament.html");
} else {
window.location.replace("./tournaments/tournament.html");
}
}
However this code does not work, because document.referrer.referrer isnt a thing. I hope you can help me and come up for a solution since i cant solve this issue on my own.
I have already tried
Solution unfortionately this isnt posible for privacy reasons so i just modified the URL wile visiting the next url. The code for that looks like this:
function nftMarked() {
if (window.location.href.indexOf("#statistics") > -1 && history.length) {
window.location.replace("./nft.html#statistics=profile?=" + document.referrer);
} else if (window.location.href.indexOf("#games") > -1 && history.length) {
window.location.replace("./nft.html#games=profile?=" + document.referrer);
} else {
window.location.replace("./nft.html");
}
}
going back to the 'document.referrer.referrer' looks like this now:
function nftStatistics() {
if(window.location.href.indexOf("#statistics") > -1 && history.length) {
history.go(-2)
} else if(window.location.href.indexOf("#games") > -1 && history.length) {
var url = String(window.location);
url = url.split("=").pop();
window.location.replace(url + "/../tournament.html")
} else {
window.location.replace("./tournaments/tournament.html");
}
}
Conclusion If you ask me this solution isnt that clean and can forward your users to any other website if they edit their URL but its the only solution i came up with. So if you have any better ideas i would be very happy to hear from you.