Home > Article > Web Front-end > jquery method to determine when the browser goes back and a message pops up_jquery
There must be some messages when the browser goes back. Here we use jquery to determine when the browser goes back and pop up a message
jQuery(document).ready(function ($) { if (window.history && window.history.pushState) { $(window).on('popstate', function () { var hashLocation = location.hash; var hashSplit = hashLocation.split("#!/"); var hashName = hashSplit[1]; if (hashName !== '') { var hash = window.location.hash; if (hash === '') { alert("Back button isn't supported. You are leaving this application on next clicking the back button"); } } }); window.history.pushState('forward', null, './#forward'); } });