I need to prevent page refresh when back button clicks in my wordpress application. I tried some solutions available online, but no use.
Here is my code in functions.php
<script>
console.log(123)
$(window).on('popstate', function(event) {
console.log("pop");
});
</script>
2
Answers
You can use this for more info read this answer How to Detect Browser Back Button event – Cross Browser
or you can use this
You can use pageshow event to handle browser navigation through your page history
Use this code may it’s Works for you