一佳一

记录像1+1一样简洁的代码

导航

禁止复制 + 锁右键 + 禁止全选(兼容IE Chrome等)

Posted on 2013-12-19 17:21  一佳一  阅读(2097)  评论(0编辑  收藏  举报

function iEsc() { return false; }
function iRec() { return true; }
function DisableKeys() {
    if (event.ctrlKey || event.shiftKey || event.altKey) {
        window.event.returnValue = false;
        iEsc();
    }
}
document.ondragstart = iEsc;
document.onkeydown = DisableKeys;
document.oncontextmenu = iEsc;
if (typeof document.onselectstart != "undefined")
    document.onselectstart = iEsc;
else {
    document.onmousedown = iEsc;
    document.onmouseup = iRec;
}
function DisableRightClick(qsyzDOTnet) {
    if (window.Event) {
        if (qsyzDOTnet.which == 2 || qsyzDOTnet.which == 3)
            iEsc();
    }
    else
        if (event.button == 2 || event.button == 3) {
            event.cancelBubble = true
            event.returnValue = false;
            iEsc();
        }
}