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

268
Visualizações
Redirect History.back() to another path with JavaScript

Expected When the user is on the /animals route, when they click the back button on the browser i want to redirect them back to another route instead of the previous route.

What's actually happening:

I am trying to redirect the url when the user clicks the back button on the browser, however i am having trouble with this where it is replacing the current location when the page loads on that route instead of replacing it when the user clicks the back button and it removes the pathname on top of that.

    if (window.location.hash === '#/animals') {
        return history.pushState({}, '', '/home');
    }
about 4 years ago · Santiago Gelvez
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