Is it possible to prevent RIGHT CLICK option for IMAGES which we use in web page.
$(document).ready(function() {
$("img").on("contextmenu",function(){
return false;
});
});
I think this should help. Trick is to bind the contextmenu event.
<script type="text/javascript" language="javascript">
$(function() {
$(this).bind("contextmenu", function(e) {
e.preventDefault();
});
});
</script>
$(document).mousedown(function(e) {
if( e.button == 2 ) {
e.preventDefault();
return false;
}
});
Method 1:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});
</script>
Method 2:
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
e.preventDefault();
});
});
</script>
Here i have found some useful link, with live working example.
I have tried its working fine.
How to prevent Right Click option using jquery
$(document).bind("contextmenu", function (e) {
e.preventDefault();
alert("Right Click is Disabled");
});
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(document).bind("contextmenu",function(e){
return false;
});
});
</script>
</head>
<body>
<p>Right click is disabled on this page.</p>
</body>
</html>