8

I've a web page(which I don't control) with:

<body oncontextmenu="return false">

I want to enable right click but there's no way I'm able to do it. In the saved html when I removed this oncontextmenu then it started working.

I've tried all mentioned here, but it's not working for me.

Here is the saved copy of web page.

Community
  • 1
  • 1
user5858
  • 1,082
  • 4
  • 39
  • 79

3 Answers3

9

Try to execute the bellow code in webdev console :

window.addEventListener("contextmenu", 
  function(e){
     e.stopPropagation()
}, true);
body,html {
  width:100%;
  height:100%;
}
<body oncontextmenu="return false">
 text
</body>
Bourbia Brahim
  • 14,459
  • 4
  • 39
  • 52
1

In 2022 and for Firefox you must place the oncontextmenu attribut to the html tag not to the body tag

<html oncontextmenu="return false">
1
window.addEventListener('contextmenu', function(e) {e.stopPropagation();e.preventDefault();}, true);

in body & html

<html oncontextmenu="return false">
<body oncontextmenu="return false">

I hope it helps navigators.

ESP
  • 11
  • 3