Wednesday 19 September 2012

How to Disable right click using jQuery

You can find many java script code snippets to disable right click. But jQuery makes our life easy. Below jQuery code disables the right click of mouse.
1$(document).ready(function(){
2    $(document).bind("contextmenu",function(e){
3        return false;
4    });
5});
See live Demo and Code
We just need to bind the contextmenu event with the document element.

Method 2 (Send from one of the reader):
1$(document).ready(function(){
2    $(document).bind("contextmenu",function(e){
3        e.preventDefault();
4    });
5});

No comments:

Post a Comment