1

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.

Skizit
  • 43,506
  • 91
  • 209
  • 269
  • AFAIK browsers don't support modification of the context menu as of yet. – zzzzBov Mar 03 '11 at 20:20
  • Most browsers do support it - Umbraco uses context menus all over their administration interface. But you will have to trap the right mouse click and write your own context menu code from scratch. – Jan Aagaard Mar 03 '11 at 20:24
  • 1
    It's usually not a good idea to change the way your users' browsers behave. If people right-click and don't get their expected menu, they may be turned off to your site. – drudge Mar 03 '11 at 20:29

2 Answers2

2

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 .

gailbear
  • 519
  • 3
  • 13
0

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/

Hussein
  • 42,480
  • 25
  • 113
  • 143