1

I am trying to show an alert when clicking the back button in Chrome. It is working properly in Firefox, but not in Chrome. Where do I need to change the code?

jQuery(document).ready(function($) {
  history.pushState(null, document.title, location.href);
  window.addEventListener('popstate', function (event) {
    history.pushState(null, document.title, location.href); 
    alert('Back button was pressed.');
  });
});
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
code_flow
  • 11
  • 2

0 Answers0