开发者

Javascript: Insert link into Mouse right click?

I'm wondering how would I include my function on my website inside 开发者_运维知识库a users right click? for example function hello() with Title Hello is an option when a user right clicks on my website.

edit: I simply wish to append to the current right click menu. Not make my own.


I'm pretty sure the answer to this is it can't be done, as right-click context menus are controlled by the browser. However, there's cool stuff like this around: http://luke.breuer.com/tutorial/javascript-context-menu-tutorial.htm .


You need to do this.

$('div').mousedown(function(event) {
    switch (event.which) {
        case 1:
            alert('Mouse left click');
            break;
        case 2:
            alert('Mouse middle click');
            break;
        case 3:
            alert('Mouse right click');
            break;
        default:
            alert('Do something else');
    }
});

Check working example at http://jsfiddle.net/2AqnW/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜