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

189
Vistas
How to pass a specific variable to go back to the previous page when the browser back button is pressed (In Javascript)?

I know how to implement a function that goes back to the previous page and takes a certain variable when a certain button is clicked.

// The 2 at the end of the url is the variable I want to pass.

<button onclick='location.href="a link that prev page has/2"'> Back to prev page </button>

However, I do not know how to pass a specific variable while returning to the previous page when the back button, which is implemented by default in the Chrome browser, is pressed.

I am trying to get the variable passed from the previous page I returned to and use it. What should I do when I click the browser back button?

If there are different functions to be implemented depending on the browser, it would be thankful if you could tell us about it as well.

+) Each page is implemented as a separate ejs file.

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

0

if you want to reload the previous page and know the path i would rather construct the link

 const new_location = location.origin + '/page'
 const new_url = new URL(new_location) 
 new_url.searchParams('param1','value')
 location = new_url

then node side you can use

 const {param1} = req.query
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