Is it possible to prevent RIGHT CLICK option for IMAGES which we use in web page.
Try this:
$(document).bind("contextmenu",function(e){
return false;
});
<body oncontextmenu="return false" onselectstart="return false" ondragstart="return false" >
Set these attributes in your selected tag
See here Working Example - https://codepen.io/Developer_Amit/pen/drYMMv
No Need JQuery (like)
Here is a working example, the red links can't be right clicked anymore.
$("ul.someLinks1 a").each(function(i, obj) {
$(obj).on("contextmenu",function(){
return false;
});
$(obj).css("color", "red");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul class="someLinks1">
<li><a href="www.google.de">google</a></li>
<li><a href="www.stackoverflow.de">stackoverflow</a></li>
<li><a href="www.test.de">test</a></li>
</ul>
<ul class="someLinks2">
<li><a href="www.foobar.de">foobar</a></li>
<li><a href="www.foo.de">foo</a></li>
<li><a href="www.bar.de">bar</a></li>
</ul>
$(document).ready(function() {
$(document)[0].oncontextmenu = function() { return false; }
$(document).mousedown(function(e) {
if( e.button == 2 ) {
alert('Sorry, this functionality is disabled!');
return false;
} else {
return true;
}
});
});
If you want to disable it only on image click the instead of $(document).mousedown
use $("#yourimage").mousedown
If you're looking into trying to disable the downloading/saving of your images, scripts won't stop that. You would probably have better luck doing this on a server configuration level (like modifying your .htaccess
for example on Apache).
Try asking this on ServerFault.
The following code will disable mouse right click from full page.
$(document).ready(function () {
$("body").on("contextmenu",function(e){
return false;
});
});
The full tutorial and working demo can be found from here - Disable mouse right click using jQuery