views:

81

answers:

2
document.addEventListener('contextmenu', function (e) {
    e.preventDefault()
    e.stopPropagation()
    e.returnValue = false
    e.cancleBubble = true
})

No way?

Edit: document.oncontextmenu = null does not work.

P.S. I cannot have the reference of the listener function since I am not the owner of the site preventing the context menu.

A: 

Rather than disabling the context menu, why don't you assign the right click event?

http://abeautifulsite.net/2008/05/jquery-right-click-plugin/

Matrym
I'm not the one who disables the context menu. Some sites disable it, and I want to break it.
lemonedo
Oh, do you mean as a greasemonkey script or something?
Matrym
+1  A: 

If you are really desperate, try adding this before the addEventListener is called. It works in both FF and Chrome. I didn't check anything else.

document.superListener = document.addEventListener;
document.addEventListener = function(type, listener, useCapture){
    if(type != 'contextmenu')
        document.superListener(type, listener, !!useCapture);
};

It may not be the best way to do things, but it should be the job done on your specific example :)

Gordon Tucker
Thank you for your answer. It seems that it is impossible to re-enable the context menu "after" the call...
lemonedo