📌  相关文章
📜  javascript 检测右键 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:46.243000             🧑  作者: Mango

代码示例1
document.body.onclick = function (e) {
    var isRightMB;
    e = e || window.event;

    if ("which" in e)  // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
        isRightMB = e.which == 3; 
    else if ("button" in e)  // IE, Opera 
        isRightMB = e.button == 2; 

    alert("Right mouse button " + (isRightMB ? "" : " was not") + "clicked!");
}