当前位置: 代码迷 >> JavaScript >> js禁止页面刷新退后
  详细解决方案

js禁止页面刷新退后

热度:483   发布时间:2012-09-06 10:37:01.0
js禁止页面刷新后退
  1. //禁止 浏览器 前进、后退
    <body onbeforeunload="history.go(0)">
    <script language="JavaScript">
      <!--
      javascript:window.history.forward(1);
    file://-->
      </script>

  2. <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>
  3. <script>? ??
  4. ???function?KeyDown(){?//屏蔽鼠标右键、Ctrl+n、shift+F10、F5刷新、退格键? ??
  5. ????//alert("ASCII代码是:"+event.keyCode);? ??
  6. ????if?(?(window.event.altKey)&&? ??
  7. ????(??(window.event.keyCode==37)||?//屏蔽?Alt+?方向键?←? ??
  8. ???????(window.event.keyCode==39)?)??){?//屏蔽?Alt+?方向键?→? ??
  9. ????????alert("不准你使用ALT+方向键前进或后退网页!");? ??
  10. ????????event.returnValue=false;? ??
  11. ????} ??
  12. ???if?((event.keyCode==8)?||?//屏蔽退格删除键? ??
  13. ???? (event.keyCode==116)||?//屏蔽?F5?刷新键? ??
  14. ???  (event.keyCode==112)||?//屏蔽?F1?刷新键? ??
  15. ???? (event.ctrlKey?&&?event.keyCode==82)){?//Ctrl?+?R? ??
  16. ???? event.keyCode=0;? ??
  17. ???? event.returnValue=false;? ??
  18. ??   alert("不准你使用快捷!");? ??
  19. ????}? ??
  20. ???if?((event.ctrlKey)&&(event.keyCode==78))?//屏蔽?Ctrl+n? ??
  21. ???{ ??
  22. ?????alert("ctrl?+?n"); ??
  23. ??  event.returnValue=false;? ??
  24. ???} ??
  25. ????if?((event.shiftKey)&&(event.keyCode==121))?//屏蔽?shift+F10? ??
  26. ??????{ ??
  27. ??????  alert("?shift+F10?"); ??
  28. ??????  event.returnValue=false;? ??
  29. ???  } ??
  30. ????if?(window.event.srcElement.tagName?==?"A"?&&?window.event.shiftKey)? ??
  31.    { ??
  32. ???   window.event.returnValue?=?false;?//屏蔽?shift?加鼠标左键新开一网页? ??
  33.    } ??
  34. ???? ??
  35. ????if?((window.event.altKey)&&(window.event.keyCode==115)){?//屏蔽Alt+F4? ??
  36.     alert('Alt+F4'); ??
  37. ????//window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");? ??
  38. ????return?false; ??
  39. }? ??
  40. ??} ??
  41. document.onkeydown?=?KeyDown??? ??
  42. </script>??
  相关解决方案