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

182
Vistas
Get previous URL with javascript

I am looking for a solution with javascript to check if the previous page is not extranal.

With this check I want return true or false so I can use this for another function.

What I have tried is to get the previous URL with history.go(-1)but this is undefined.

I am happy if I can get the previous URL so far.

Hope somebody can help me out with this.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can use document.referrer to get the URL of the previous page.

To check whether it is external or not, you can parse it with the URL constructor and compare its origin.

const previousURL = document.referrer;

const isPreviousURLExternal = new URL(previousURL).origin == new URL(location).origin;
console.log(isPreviousURLExternal)

about 4 years ago · Juan Pablo Isaza 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