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

551
Views
How do you trigger an event when the URL changes without the page reloading in javascript?

For example, if I click the 'next' button on a webpage, the website displays the results of the next page but does not reload the page, whilst the URL changes. How would I detect this change in URL and trigger an event accordingly on the newly displayed page?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

After click 'next' button you would do action which get new URL address and do action based on the new data.

For example:


nextBtn.addEventListener('click', () => {
  const currentLocation = window.location;
  // here you can get data from URL and do whatever you want with it
});

But you can also use library like rxjs to subscribe url from others files.

For example:

file1.js

nextBtn.addEventListener('click', () => {
  const currentLocation = window.location;
  publisher.next(currentLocation);
});

file2.js
publisher.subscribe(location => {
  // and you have your url data in another file
});

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!