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

162
Vistas
How to check current page url in javascript?

I want to check if I am in certain domain, like this (in manifest.json for chrome extensions):

"content_scripts": [
{
  "matches": ["*://certain.site/*"],
  "js": ["some.js"]
}

But it seems like there are only dirty ways in javascript, like .split("/") which I don't want to use. Is there a clean way to do it?

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

0

You can use the URL interface for that. Like:

const currentUrl = new URL(window.location.href);

Now you can get the things like path and hostname from the currentUrl, like currentUrl.pathname.

To get only the file name you now can do: currentUrl.pathname.split('/').pop()

about 4 years ago · Juan Pablo Isaza Denunciar

0

you get detail of URL

console.log(location);

get current url

console.log(location.href);
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