zoukankan      html  css  js  c++  java
  • OnContextMenu事件(转)

    用oncontextmenu事件单禁用右键菜单
    一个页面中,BODY中用oncontextmenu='return false'来取消鼠标右键;在JS中设置oncontextmenu='return true'用window.document.oncontextmenu = function(){ return false;}
    onconTextmenu=window.event.returnValue=false;右键菜单禁用,用这个可以禁止复制。
    在<body>中加入属性代码:
    oncontextmenu="return false"              
    onselectstart="return false"                   禁止选中网页上的内容
    oncopy="return false"                           防复制用户在网页上选中的内容
    防止用户另存网页:
    利用<noscript><iframe src=*.html></iframe></noscript>标签,能防止网页的直接另存,但不能防止网页被人使用工具下载
    *为通配符。
    例1:
    <html>
    <head>
    <title>OnContextMenu事件</title>
    <script language="JavaScript">
    <!--
    function uFunction()
    {     document.all.infoDiv.innerHTML='你按下了鼠标右键,但是右键菜单不能 显示!';}
    function uFunction2()
    {    document.all.infoDiv.innerHTML='你按下了Ctrl+鼠标右键,可以 显示右键菜单。';}
    //-->
    </script>
    </head>
    <body oncontextmenu="if(!event.ctrlKey){uFunction();return false}else{uFunction2()}">
    <div id="infoDiv">你按下了鼠标右键,但是右键菜单不能 显示!<br>你按下了Ctrl+鼠标右键,可以显示右键菜单。
    </div></body>
    </html>

  • 相关阅读:
    topcoder srm 445 div1
    topcoder srm 440 div1
    topcoder srm 435 div1
    topcoder srm 430 div1
    topcoder srm 400 div1
    topcoder srm 380 div1
    topcoder srm 370 div1
    topcoder srm 425 div1
    WKWebView强大的新特性
    Runtime那些事
  • 原文地址:https://www.cnblogs.com/Hcjer/p/4022582.html
Copyright © 2011-2022 走看看