zoukankan      html  css  js  c++  java
  • js屏蔽浏览器(IE和FireFox)的刷新和右键等功能

    一,js屏蔽浏览器(IE和FireFox)的刷新功能

     document.onkeydown=function()
    {
    if ((window.event.keyCode==116)|| //屏蔽 F5
    (window.event.keyCode==122)|| //屏蔽 F11
    (window.event.shiftKey && window.event.keyCode==121) //shift+F10
    )

    window.event.keyCode=0;
    window.event.returnValue=false;

    if ((window.event.altKey)&&(window.event.keyCode==115)){ //屏蔽Alt+F4
    window.showModelessDialog("about:blank","","dialogWidth:1px;dialogheight:1px");
    return false;
    }
    }

     

    二,屏蔽右键

    if (window.Event) 
    document.captureEvents(Event.MOUSEUP); 
    function nocontextmenu(){ 
     event.cancelBubble = true 
     event.returnValue = false; 
     return false; 

    function norightclick(e){ 
     if (window.Event){ 
      if (e.which == 2 || e.which == 3) 
      return false; 
     } 
     else 
      if (event.button == 2 || event.button == 3){ 
       event.cancelBubble = true 
       event.returnValue = false; 
       return false; 
      } 

    document.oncontextmenu = nocontextmenu; // for IE5+ 
    document.onmousedown = norightclick; // for all others

  • 相关阅读:
    第24课 多线程开发
    第23课 装饰器
    第22课 调用外部程序
    第20课 异常处理
    第19课 习题讲解
    第18课 面向对象
    第17课 调试程序
    第16课 pycharm 使用
    第15课 模块与包
    第14课 再识函数
  • 原文地址:https://www.cnblogs.com/zzh/p/1414150.html
Copyright © 2011-2022 走看看