js禁止右键

    xiaoxiao2021-12-10  14

    //网页上禁止用户点击右键 function prohibitRightClick() { 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; document.onmousedown = norightclick; document.onkeydown = function() { if (event.ctrlKey && window.event.keyCode == 67) { return false; } }; document.body.oncopy = function() { return false; }; document.onselectstart = function() { return false; }; } prohibitRightClick();
    转载请注明原文地址: https://ju.6miu.com/read-700229.html

    最新回复(0)