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

138
Views
Popstate event is not firing on mobile after adding touch event listeners

I'm adding a new entry to my browser's history stack with pushState. Now popstate event should fire when pressing the back button, right? And at least on mobile, it requires some kind of user action before pressing the back button to fire (scroll or touch).

This is my current situation and it is working nicely on mobile if I click or scroll a bit before pressing the back button.

Now if I add touchstart, touchmove or touchend event listener then popstate event is firing only if I perform touch first and then press the back button. But it is not firing if I scroll only and do not perform touch.

Below are two snippets of code that explain the situation.

Alert is shown, only small scroll is required before pressing back button:

window.addEventListener('popstate', () => {
    alert('This is test');
});

Alert is not shown, requires click before pressing back button:

window.addEventListener('popstate', () => {
    alert('This is test');
});

document.addEventListener('touchmove', () => {
    // Empty eventListener here
});

Any ideas why it is not working with scroll-only after adding touch event listeners?

about 4 years ago · Juan Pablo Isaza
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!