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/
精彩评论