Disable right click using jquery

Disable right click With the given code you can simply disable right click on hole of the page. However you can also disable right click on particular element.

$(document).bind(‘contextmenu’, function (e) {
e.preventDefault();
alert(‘Right Click is not allowed’);
});

Though disabling right click with any code not is complete solution to save the data, there are many tool to get your image or source code, but it will make task difficult for normal user.

CODE

<!DOCTYPE html> <html> <head> <title>jQuery With Example</title> http://a%20href=  $(function () { $(document).bind('contextmenu', function (e) { e.preventDefault(); alert('Right Click is not allowed'); }); /*$('.Container').bind('contextmenu',function(e){ e.preventDefault(); alert('Right Click is not allowed on div'); });*/ });  </head> <body> 

Please right Click here for test this example


<button id="btnClick">Click</button> </body> </html>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

WordPress.com.

Up ↑

%d bloggers like this: