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

138
Visualizações
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 Respostas
Responde à pergunta

0

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

window.location.pathname
about 4 years ago · Juan Pablo Isaza Relatório

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 Relatório

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 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