Archived topic
How to disable right click in wordpress without any plugin
6 replies · Started by Carlos on June 13, 2020
Hello there,
I need to add code for to disable right click on WordPress without any plugin, add any codes but not working and broken the site.
I don't want other plugin, have 21 plugins and I'm wish delete plugins 1 to 1 but need options.
Thank you very much!
Hi there,
this article provides the one line of JS you require and some very good reasons why you shouldn't:
Hello David,
where I should add this code?
document.addEventListener('contextmenu', event => event.preventDefault());
In my functions? I'm using the child theme.
Thank you very much
Simplest way.
Create a new Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
Add the script like so:
<script>
// Code goes here
</script>
Select the WP_Footer hook.
And set the Display Rules to Entire Site.
Hello David,
the code is not working. Your code only disable the right click but not the copy and paste.
Please I need your help.
Thank you very much!
Hello there!
This code here working like charm !
<body oncontextmenu="return false" onselectstart="return false"
onkeydown="if ((arguments[0] || window.event).ctrlKey) return false"></body>
Thank you very much!
Glad to hear that