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

    禁止右键复制

    <script>
        //禁止右键
        document.writeln("<noscript><iframe src=""></iframe></noscript>");
        function getCookie(objName) {//获取指定名称的cookie的值
            var arrStr = document.cookie.split("; ");
            for (var i = 0; i < arrStr.length; i++) {
                var temp = arrStr[i].split("=");
                if (temp[0] == objName) return unescape(temp[1]);
            }
        }
        function addCookie(objName, objValue, objHours) {//添加cookie
            var str = objName + "=" + escape(objValue);
            if (objHours > 0) {//为0时不设定过期时间,浏览器关闭时cookie自动消失
                var date = new Date();
                var ms = objHours * 3600 * 1000;
                date.setTime(date.getTime() + ms);
                str += "; expires=" + date.toGMTString();
            }
            document.cookie = str;
        }
        if (location.href != getCookie("orderfrom")) {
            addCookie("orderfrom", location.href, 0);
        }
        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
        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;
        }
        //获取订单地址
        var url=(window.location.href);
    </script>
  • 相关阅读:
    golang的string是包使用
    OTHER状态的mongodb副本集成员转换为独立的新副本集primary
    linux命令行快捷键
    如何配置vcodes成最美观的样子,让你从此爱上代码
    记一次Lock wait timeout异常的排查过程
    mysql变更上线流程
    go build 使用
    Makefile文件
    解决 windows10系统和AOC显示器时不时地闪现黑屏问题
    feign调用添加header参数
  • 原文地址:https://www.cnblogs.com/wzzl/p/4962501.html
Copyright © 2011-2022 走看看