Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
JavaScript: document.referrer (2x)

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

  1. Searching the Internet
  2. Searching the Internet for alternatives
  3. Asking friends
about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

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.

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda