[JS] 屏蔽右键

2021-07-02 15:06

阅读:628

标签:contex   htc   context   down   win   other   span   blog   elb   

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  

 

[JS] 屏蔽右键

标签:contex   htc   context   down   win   other   span   blog   elb   

原文地址:http://www.cnblogs.com/frost-yen/p/7127937.html


评论


亲,登录后才可以留言!