I am working on a Whatsupjokes.com which is a jokes sharing website. I want to disable right button, so they will not copy my content.
How can I achieve this using JavaScript?
I am working on a Whatsupjokes.com which is a jokes sharing website. I want to disable right button, so they will not copy my content.
How can I achieve this using JavaScript?
use this following code in themes\yourtheme\function.php file
function your_function() {
?>
<script>
jQuery(document).ready(function(){
jQuery(document).bind("contextmenu",function(e){
return false;
});
});
</script>
<?php
}
add_action('wp_footer', 'your_function');
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});
Keep in mind it won't work on iframes if you use any (you would have to add the same script in each frame). Also disabling the right click you won't achieve a thing since there is so many other ways to copy the content, like selecting it with left click and using ctrl+c, ctrl+v or taking all the effort to save entire page if your jokes are that good rolls eyes.
You can use this code for rightclick, ctrl-c, ctrl-v, ctrl-x
$(document).bind('copy', function(e) {
alert('Copy is not allowed !!!');
e.preventDefault();
});
$(document).bind('paste', function() {
alert('Paste is not allowed !!!');
e.preventDefault();
});
$(document).bind('cut', function() {
alert('Cut is not allowed !!!');
e.preventDefault();
});
$(document).bind('contextmenu', function(e) {
alert('Right Click is not allowed !!!');
e.preventDefault();
});