Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!