首页 > 代码库 > 禁止浏览器右键与复制功能

禁止浏览器右键与复制功能


var ProhibitRightCopy = function () { (function () { })(); //禁止右键 function ProhibitRight(range) { if (range == undefined || range.length <= 0) { range = document.body; } else { range = $(range).get(0); } range.oncontextmenu = function () { return false; } } //禁止复制 function ProhibitCopy(range) { if (range == undefined || range.length <= 0) { range = document.body; } else { range = $(range).get(0); } range.onkeydown = function () { if (event.ctrlKey && window.event.keyCode == 67) { return false; } } range.oncopy = function () { return false; } } return { ProhibitRight: ProhibitRight, ProhibitCopy: ProhibitCopy } }()

 //实际使用

    <script>
        $(function () {
            ProhibitRightCopy.ProhibitRight($(".Select"));
            ProhibitRightCopy.ProhibitCopy($(".Select"));
        })
    </script>

 

禁止浏览器右键与复制功能