CSS: Prevent Right Click

By Xah Lee. Date: . Last updated: .

Prevent Right Click

to prevent right click, use this JavaScript

document.addEventListener ('contextmenu', (x => x.preventDefault ()) , false);

user-select Property

Prevent text selection.

Note, this does not work for right-click menu.

body {user-select: none;}

Note: does not work in Safari nor Firefox as of 2019-02-26

Possible values:

user-select:auto
inital value.
user-select:none
not selectable.
user-select:text
selectable.
user-select:contain
(not much used)
user-select:all
(not much used)