Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent Right Click option using jquery

Tags:

jquery

Is it possible to prevent RIGHT CLICK option for IMAGES which we use in web page.

like image 969
mymotherland Avatar asked Apr 11 '11 07:04

mymotherland


People also ask

How do I disable right click on a specific div?

Disable right click menu in html page using jquery. JavaScript Code: $(document). bind("contextmenu",function(e){ return false; });

How do I disable F12 and right click on my website?

Also disable the F12 , Ctrl + Shift + I , Ctrl + Shift + J and Ctrl + U keys. Instead of the contextmenu event, You can also add the oncontextmenu handler into the HTML body tag to disable the right click.


2 Answers

$(document).ready(function() {     $("img").on("contextmenu",function(){        return false;     });  });  

Working example: http://jsfiddle.net/vak9exyk/

like image 155
Peeter Avatar answered Oct 06 '22 12:10

Peeter


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> 
like image 40
Abdul Kader Avatar answered Oct 06 '22 12:10

Abdul Kader