开发者

ContextMenu enabling issue

开发者 https://www.devze.com 2023-02-16 18:41 出处:网络
For the body tag I have context开发者_StackOverflow中文版Menu disabled. <body oncontextmenu=\"return false\">

For the body tag I have context开发者_StackOverflow中文版Menu disabled.

<body oncontextmenu="return false">

But in my application one element, which is inside the body, needs the right click enabled. How to enable it for one particular div/element?


Inside the oncontextmenu handler, check if the target element has a particular id, className or some other property.

document.body.oncontextmenu = function (e) {
    if (e.target.id !== 'that-div') { return false }
}

Example: http://jsfiddle.net/eWBUR/

0

精彩评论

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

关注公众号