Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda