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

166
Visualizações
window.history.back() won't take me back to homepage

I'm creating a website right now with multiple pages, that you access through the homepage however, each page has a back button that takes you back to the previous page, however the back button doesn't take me back to the homepage and will instead take me back to the page before that. I noticed that if I click once into a separate link from the homepage that new link will overwrite the homepage from my browser history. What is the explanation for this and what is the fix?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

To go back to the home page, you can try the code below:

location.href = "/";
about 4 years ago · Juan Pablo Isaza Relatório

0

Tha is the expected behaviour as per MDN

The History.back() method causes the browser to move back one page in the session history. It has the same effect as calling history.go(-1). If there is no previous page, this method call does nothing.

To go back to the homepage, you can provide a static link to your website homepage, similar to www.example.com

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