Jquery disable right click, cut, copy and paste example

By Hardik Savani | March 22, 2019 | | 9161 Viewer | Category : Javascript jQuery


I will show you how to prevent mouse right click, cut copy paste in your web page, div, image, element, iframe etc. so basically you can not right click or copy paste from your browser.

we will use context menu for disable mouse right click.

we will use bind event with cut copy paste operation for preventing copy, cut and paste options. you can same perform with javascript to prevent right click.

In this example, we will simple include jquery using cdn file. than we will write code to disable cut copy paste from whole page after that write contextmenu event for disable mouse right click. So let's just see bellow html code and use it.

Example:

<!DOCTYPE html>

<html>

<head>

<title>Jquery disable right click, cut, copy and paste example - ItSolutionstuff.com</title>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

</head>

<body>

<h1>Jquery disable right click, cut, copy and paste example - ItSolutionstuff.com</h1>

<script type="text/javascript">

$(document).ready(function () {

//Disable cut copy paste

$(document).bind('cut copy paste', function (e) {

e.preventDefault();

});

//Disable mouse right click

$(document).on("contextmenu",function(e){

return false;

});

});

</script>

</body>

</html>

I hope it can helper you...



Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
***Do you want me hire for your Project Work? Then Contact US.


We are Recommending you: