Why can't I use addEventListener to stop contextmenu event?
dom-events, javascript
Solution
As stated in "Preventing the Browser's Default Action", the return of `false` value is not enough for preventing default action. You need to call `preventDefault()` method on `Event` object:
document.addEventListener('contextmenu', function(event) {
event.preventDefault();
}, true);
DEMO
Problem
I want to prohibit the right mouse button, but I find that if I write this: ``` document.addEventListener('contextmenu', function(event) { return false; }, false); ``` It will not work, the event will still work. But if I write it like this, ``` document.oncontextmenu = function() { return false; } ``` The right mouse button will not work. I wish to know why I can't use `addEventListener` to stop the event `contextmenu`.