瀏覽器后退時必定會有一些消息,這里使用jquery判斷瀏覽器后退并彈出消息
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');}});
新聞熱點
疑難解答