开发者

jQuery / Javascript: fire a rightclick on a normal-click?

开发者 https://www.devze.com 2023-01-13 15:28 出处:网络
i don\'t think so but i couldn\'t find a quick answer! is it possible to show the browsers rightc开发者_StackOverflowlick (context) menu when clicking the left mouse trigger?

i don't think so but i couldn't find a quick answer! is it possible to show the browsers rightc开发者_StackOverflowlick (context) menu when clicking the left mouse trigger?

thank you


You can't emulate physical browser clicks, such as bringing up the context menu, for security reasons. The closest you'll get to is trapping the click event, which can be done with:

http://jsfiddle.net/zysZC/

$(window).mousedown(function(e) {
    if (e.which == 1) { // Left mouse button, 2 = middle, 3 = right
        alert('left clicked');
    }
});

You may also be interested in this plugin: http://abeautifulsite.net/blog/2008/05/jquery-right-click-plugin/

0

精彩评论

暂无评论...
验证码 换一张
取 消