roopesh
roopesh

Reputation: 21

ContextMenu enabling issue

For the body tag I have contextMenu 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?

Upvotes: 2

Views: 219

Answers (1)

pimvdb
pimvdb

Reputation: 154838

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/

Upvotes: 2

Related Questions