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

171
Vistas
JavaScript remove last History entries with same URL

I have a POST form (simple HTML, no JS involved in submission) which is partially validated server-side. When I submit it, server may return a redirect if there are any errors. Let’s say, the form is on /myform URI, but if the server found errors in data it will redirect to /myform?error. After this is done several times and finally correctly submitted, user may want to use his browser’s back button. But it makes user to go through all the steps of failed submission attempts, e.g. /myform?success -> /myform?error -> /myform -> /home.

How do I prevent this? My guess is to remove last History entries that have same URI. How do I achieve that? Or is there another better way? I use server side rendering with Spring (Java) so dynamic validation is not really an option for the use-case. Thank you in advance!

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

0

For security and privacy reasons, you can't view or modify a user's browser history.

However, if you're willing to use JavaScript, you can use the History API to replace the current page's state on successful submit:

history.replaceState(null, 'Page title', '/form-url');

https://developer.mozilla.org/en-US/docs/Web/API/History_API

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