1.能夠消除 後退的全部動做。包括 鍵盤、鼠標手勢等產生的後退動做。javascript
<script language="javascript"> //防止頁面後退 history.pushState(null, null, document.URL); window.addEventListener('popstate', function () { history.pushState(null, null, document.URL); }); </script>
2.系統登陸退出後,跳轉到登陸頁面,登陸頁面點擊瀏覽器後退按鈕,頁面後退到以前登陸的頁面。在退出登陸後,禁止瀏覽器點擊後退按鈕,進行頁面回退;前端
window.location.hash="no-back"; window.location.hash="Again-No-back-button"; window.onhashchange=function(){window.location.hash="no-back";}
3.系統中嵌入iframe,映入其餘頁面。當session失效時,點擊導航後,因爲後臺作了登陸攔截,此時iframe中就會嵌入登陸頁面;當session失效時,但願系統能夠跳轉到登陸頁面中;java
/** * [loadTopWindow 判斷是否有頂層窗口,登陸超時跳轉] * @return {[type]} [description] */ function loadTopWindow() { if (window.top != null && window.top.document.URL != document.URL){ window.top.location = document.URL; } } <body onload="loadTopWindow()"></body>
整理了一些項目實戰的學習視頻,好友都會在裏面交流,分享一些學習的方法和須要注意的小細節,天天也會準時的講一些前端的炫酷特效,及前端直播課程學習。【 731771211 】瀏覽器