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

209
Vistas
PushState requires two "go back" but then "go forward" will stop working

I have a very rudimentary SPA built in vanilla JS. There are two buttons that the user can use to navigate between pages, for example:

buttonProfile.addEventListener("click", function () {
  window.history.pushState({}, "", "profile/");
  var updatePage = new Event("update-page");
  dispatchEvent(updatePage);
});

Somewhere in the app, I have an event listener that listens to update-page to refresh the content that needs to be refreshed (without ever reloading the page) based on the current URL. Everything works fine.

However, I noted two odd behaviours:

  • If the user starts on Page A and then moves to Page B, the user will need to go back twice (button on the browser) in order to go back to Page A.
  • If the user goes back from Page B to Page A, once they are back to Page A the "forward" button on the browser will become greyed out.

EDIT

In case it helps, I noted I have the same issue when I use other people's SPAs that have a similar implementation. See this simple demo for example: DEMO | CODE

Steps to reproduce:

  • Click on About, then Contact, then again About, then again Contact.
  • Now, if you press Back once you'll go back to About. However, if you press it again you'll stay on About. You'll have to press it again to move to Contact and once you do, the Forward button will be disabled.

EDIT 2

I just realize that both my site and the site I posted above work fine when I run my browser in Incognito. There must be some other problem with my Chrome (though I have no idea what).

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Okay, I found it. It was the Matter official Chrome extension. Not sure what exactly caused the issue though.

about 4 years ago · Santiago Trujillo 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