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.

1

2 Answers 2

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();
}
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.