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

198
Visualizações
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 Respostas
Responde à pergunta

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 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