0

I'm developing a PWA and there is a conflict between a library I use for loading and back button

The only thing I need to detect is whether user clicked back button in their mobile (PWA) or not. Then I can handle the rest.

I searched but did not find anything for my case. I don't want to prevent it from happening, I just want to detect that's it. And I think mobile back button and browser back button are the same in PWA

Detect if user clicked back button or not.

Danny
  • 1
  • 2
  • 1
    Does this answer your question? [How can I control the back button event in jQuery Mobile?](https://stackoverflow.com/questions/18211984/how-can-i-control-the-back-button-event-in-jquery-mobile) – Kundan Dec 18 '22 at 07:32

2 Answers2

0

detect browser back

window.onhashchange = function() {
 //blah blah blah
}
function goBack() {
    window.location.hash = window.location.lasthash[window.location.lasthash.length-1];
    //blah blah blah
    window.location.lasthash.pop();
}
devsakil
  • 41
  • 2
0

use popstate on window obj window.addEventListener('popstate', callBackFn);

whenever use will click on back button popstate event will get triggered