14

This is a random Chinese website http://www.soap-china.com/index.asp

I noticed that right click is disabled. I always have JavaScript off, so I started delete node by node, css line by line in Firebag, but didn't find out what is disabling right click.

How does it work?

This is not first time I see this, so I am curious about this trick.

Qiao
  • 15,903
  • 28
  • 85
  • 117
  • Wow, that’s really something. I would have guessed `pointer-events: none` (since selection doesn’t work either), but it’s not that. Flash, maybe, but that’s not everywhere. Good question! – Ry- Aug 31 '14 at 22:27
  • There’s the `onselectstart="return false"`, but that is, of course, JavaScript… – Ry- Aug 31 '14 at 22:31
  • Seams like NoScript bag, asked here: https://forums.informaction.com/viewtopic.php?f=7&t=20026 – Qiao Aug 31 '14 at 22:51

6 Answers6

28

On the body Tag do this:

<body oncontextmenu="return false">
...
</body>
Umer Qureshi
  • 1,696
  • 2
  • 18
  • 22
  • 7
    Well, simple and effective. Great answer. – xZero Mar 11 '15 at 11:44
  • 1
    If your body does not cover the whole screen and you want to disable right click on the whole screen, use this with the html tag. ` ... `. Helped me in a Chromium Kiosk with Raspberry Pi OS Buster. – nsssayom Sep 08 '20 at 07:24
12

It is done with javascript.

I have disabled javascript and I can right-click. It disables with:

<script language="JavaScript">
document.oncontextmenu =new Function("return false;")
</script>    
<body onselectstart="return false">

There might be an issue with your browser, the site is online for me.

Claudiu Creanga
  • 7,394
  • 10
  • 62
  • 103
  • 1
    Yep. That is strange, but NoScript doesn't stop this script. So it is NoScript bag. I should check default javascript off. – Qiao Aug 31 '14 at 22:43
6

You can use user-select in CSS on any elements you don't want to be clicked on. Variants are needed for some older browsers though. As follows;

-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
worldofjr
  • 3,809
  • 8
  • 33
  • 48
1

The best way to do this :

<script type="text/javascript">
document.oncontextmenu =new Function("return false;")
document.onselectstart =new Function("return false;")
</script>

Good luck.

HichamEch
  • 578
  • 8
  • 18
0

It's a simple Javascript snippet.
Disabling Javascript on the page removes the effect, you possibly forgot you had turned it on on your browser.
At the top of their <body>:

<script language="JavaScript">
    document.oncontextmenu =new Function("return false;")
</script>
Etheryte
  • 22,936
  • 11
  • 65
  • 109
-2

Or you can always do this simple method

add the oncontextmenu handler to it as

<body oncontextmenu="return false">