Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery - Add entry to the rightclick contextmenu

Tags:

jquery

you can disable the menu

$(document).bind("contextmenu", function(e) {
    return false;
});

you can show a div

$(document).bind("contextmenu", function(e) {

    $('#menu').css({
        top: e.pageY+'px',
        left: e.pageX+'px'
    }).show();

    return false;

});

but is it possible only to add an entry to the rightclick contextmenu?

Thanks in advance!
Peter

like image 998
Peter Avatar asked Sep 06 '25 06:09

Peter


2 Answers

Not in JavaScript no...this could have some pretty malicious uses.

You can create your own menu (like your <div> example), but not add items to the native browser context menu.

like image 143
Nick Craver Avatar answered Sep 07 '25 19:09

Nick Craver


Thanks to HTML5 this is possible now: http://davidwalsh.name/demo/html5-context-menu.php

like image 24
iamtimeshift Avatar answered Sep 07 '25 19:09

iamtimeshift