Answers for "if left click or right click statement in javascript"

0

javascript detect right click

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!");
}
Posted by: Guest on September-05-2019
0

if left click or right click statement in javascript

alert("Right mouse button " + (isRightMB ? "" : " was not") + "clicked!");
Posted by: Guest on May-27-2021

Code answers related to "if left click or right click statement in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language