瀏覽器后退時(shí)必定會(huì)有一些消息,這里使用jquery判斷瀏覽器后退并彈出消息
view source
print?01 jQuery(document).ready(function ($) {
02 if (window.history && window.history.pushState) {
03 $(window).on('popstate', function () {
04 var hashLocation = location.hash;
05 var hashSplit = hashLocation.split("#!/");
06 var hashName = hashSplit[1];
07 if (hashName !== '') {
08 var hash = window.location.hash;
09 if (hash === '') {
10 alert("Back button isn't supported. You are leaving this application on next clicking the back button");
11 }
12 }
13 });
14 window.history.pushState('forward', null, './#forward');
15 }
16 });
更多信息請(qǐng)查看IT技術(shù)專欄
2025國(guó)考·省考課程試聽(tīng)報(bào)名