zoukankan      html  css  js  c++  java
  • JS 禁止IE用右键

    <!--组合键: -->
    IE的键盘监听最多只能作用于document上(window我试过不行)
    如果内嵌了iframe并且你的焦点在iframe上,那么按键无效
    这里我用CTRL+Q写的例子:
    function test(){
      if(event.ctrlKey&&window.event.keyCode==81){
        myalert();
      }
    }

    <!--禁止网页右键: -->

    document.body.oncontextmenu=function rightClick(){ window.event.returnValue= false;}

    <!--禁止网页另存为: -->
    <noscript><iframe src=*.html></iframe></noscript>

    <!-- 禁止选择文本: -->
    <script type="text/javascript">

    var omitformtags=["input", "textarea", "select"]

    omitformtags=omitformtags.join("|")

    function disableselect(e){
    if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
    return false
    }

    function reEnable(){
    return true
    }

    if (typeof document.onselectstart!="undefined")
    document.onselectstart=new Function ("return false")
    else{
    document.onmousedown=disableselect
    document.onmouseup=reEnable
    }
    </script>

    <!-- 禁用右键: -->
    <script>
    function stop(){
    return false;
    }
    document.oncontextmenu=stop;
    </script> 

  • 相关阅读:
    C++计时器:毫秒级和微秒级
    28款GitHub最流行的开源机器学习项目
    图像旋转公式 旋转中心点
    JNA
    this
    Random Javascript code snippets
    type
    TreeView的异步延时加载
    C#递归所以部门展示到TreeView
    C#判断是否是节假日
  • 原文地址:https://www.cnblogs.com/lbjz/p/3495334.html
Copyright © 2011-2022 走看看