js禁止頁面重新整理與後退的方法,js頁面重新整理後退

來源:互聯網
上載者:User

js禁止頁面重新整理與後退的方法,js頁面重新整理後退

本文執行個體講述了js禁止頁面重新整理與後退的方法。分享給大家供大家參考。具體實現方法如下:

<script language="javascript">//禁止用F5鍵function document.onkeydown(){    if ( event.keyCode==116)  {       event.keyCode = 0;    event.cancelBubble = true;    return false;  }}//禁止右鍵快顯功能表 function document.oncontextmenu(){      return false;   }//下面代碼實現全螢幕顯示 function window.onload(){    var Request = new Array();//儲存參數    var s = location.search.substring(1);    if (s && s!=""){     var list = s.split("&");    for (var i=0; i < list.length; i++){    var pair = list[i].split("=");    if (pair[0] && pair[0] !=""){    Request[unescape(pair[0])] = unescape(pair[1]);    }    }   }   var fullscreen=Request["fullscreen"];   if(fullscreen!="yes"){    var file =self.location;    var a = window.open("about:blank","","fullscreen=yes");    self.opener=null;    self.close();    a.location=file + "?fullscreen=yes";   }}</script><script language="Javascript"><!--//屏蔽滑鼠右鍵、Ctrl+N、Shift+F10、F11、F5重新整理、退格鍵  //Author: meizz(梅花雨) 2002-6-18  function document.oncontextmenu(){event.returnValue=false;}//屏蔽滑鼠右鍵function window.onhelp(){return false}//屏蔽F1協助  function document.onkeydown()  {  if ((window.event.altKey)&&  ((window.event.keyCode==37)|| //屏蔽 Alt+ 方向鍵 ←  (window.event.keyCode==39))) //屏蔽 Alt+ 方向鍵 →  {  alert("不準你使用ALT+方向鍵前進或後退網頁!");  event.returnValue=false;  }  /* 註:這還不是真正地屏蔽 Alt+ 方向鍵, 因為 Alt+ 方向鍵彈出警告框時,按住 ALT 鍵不放, 用滑鼠點掉警告框,這種屏蔽方法就失效了。以後若 有哪位高手有真正屏蔽 ALT 鍵的方法,請告知。*/  if ((event.keyCode==8) || //屏蔽退格刪除鍵  (event.keyCode==116)|| //屏蔽 F5 重新整理鍵  (event.ctrlKey && event.keyCode==82)){ //Ctrl + R  event.keyCode=0;  event.returnValue=false;  }  if (event.keyCode==122){event.keyCode=0;event.returnValue=false;}//屏蔽F11  if (event.ctrlKey && event.keyCode==78) event.returnValue=false; //屏蔽 Ctrl+n  if (event.shiftKey && event.keyCode==121)event.returnValue=false;//屏蔽 shift+F10  if (window.event.srcElement.tagName == "A" && window.event.shiftKey)  window.event.returnValue = false; //屏蔽 shift 加滑鼠左鍵新開一網頁  if ((window.event.altKey)&&(window.event.keyCode==115)) //屏蔽Alt+F4  {  window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");  return false;  }  }  </script>

希望本文所述對大家的javascript程式設計有所協助。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.