开发者

Jquery - Add entry to the rightclick contextmenu

开发者 https://www.devze.com 2023-01-18 01:44 出处:网络
you can disable the menu $(document).bind(\"contextmenu\", function(e) { return false; }); you can show a div

you can disable the menu

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

you can show a div

$(document).b开发者_高级运维ind("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


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.


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


There is a nice jquery plugin, called "contextMenu" :)

http://medialize.github.io/jQuery-contextMenu/demo.html

I use it and its very easy to customize.

0

精彩评论

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