Is right click a Javascript event?

后端 未结 18 2117
南笙
南笙 2020-11-22 10:02

Is right click a Javascript event? If so, how do I use it?

18条回答
  •  粉色の甜心
    2020-11-22 10:38

    Yes - it is!

    function doSomething(e) {
        var rightclick;
        if (!e) var e = window.event;
        if (e.which) rightclick = (e.which == 3);
        else if (e.button) rightclick = (e.button == 2);
        alert('Rightclick: ' + rightclick); // true or false
    }
    

提交回复
热议问题