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

135
Vistas
JavaScript get portion of a page URL

Is there a way using HTML css and JavaScript that I can find the URL of a webpage after the first 10 characters. For example, if the URL is random.com/abc the program would only get the /abc part of the URl and log it in the console. How can this be done?

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

0

You need to get the pathname from the window location object.

window.location.pathname
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can use window.location.href along with substring() to select a range of characters or characters after a particular index.

window.location.href.substring(10);
about 4 years ago · Juan Pablo Isaza Denunciar

0

To get the path, use the pathName.

console.log(window.location.pathname);
console.log((new URL('http://www.example.com/abc/123')).pathname);

There is no reason to split and use indexes.

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