zoukankan      html  css  js  c++  java
  • 禁止右键二种方法

    一、jquery

    <script type="text/javascript">
        $(document).ready(function() {
            $(document).bind("contextmenu", function(e) {
                return false;
            });

    //            $(document).bind("selectstart", function(e) {
    //                return false;
    //            });

    //            $(document).bind("onpaste", function(e) {
    //                return false;
    //            });


        });
    </script>

    二、javascript

     <noscript>
            <iframe src="jz.htm"></iframe>
        </noscript>

        <script language="JavaScript">
    <!--

            function key() {
                if (event.shiftKey) {
                    window.close();
                }
                //禁止shift
                if (event.altKey) {
                    window.close();
                }
                //禁止alt
                if (event.ctrlKey) {
                    window.close();
                }
                //禁止ctrl
                return false;
            }
            document.onkeydown = key;
            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
    //-->
        </script>

  • 相关阅读:
    js 实现 间隙滚动效果
    js实现无缝滚动
    js 实现弹出层效果
    jQuery实现网页定位导航
    右侧定位的样式
    jQuery实现点击按钮展开和收起
    js实现点击按钮控制展开与收起.
    【BZOJ1202】[HNOI2005]狡猾的商人 带权并查集
    【BZOJ1067】[SCOI2007]降雨量 RMQ+特判
    【BZOJ1367】[Baltic2004]sequence 左偏树
  • 原文地址:https://www.cnblogs.com/zwei1121/p/1793810.html
Copyright © 2011-2022 走看看