Disable Right Click on Web Page and Image in ASP.NET


Sometimes you want to prevent user from right clicking on your web pages or images from being copied. It may be because of some security reasons. You can secure your web pages or images by disabling right click.

Please note that, It is impossible to prevent webpages or images from being stolen/copied completely, since there are so many tools and utilities through which one can copy yours images.

To achieve this, Add the below event handler to the image tag.

Disable right click on images:

1. Javascript Approach:


<img src="http://i250.photobucket.com/albums/gg247/dsuraj/General/disablerightclick_zpscc89f5c6.png" oncontextmenu="return false;" />

2. jQuery Approach:


$('img').bind('contextmenu', function(e){
return false;
});

jsFiddle example

Disable right click on a web page:

1. Javascript Approach:


<html>
<head>
...
</head>
<body oncontextmenu="return false;" >
...
</body>
</html>

2. jQuery Approach:


$(document).bind("contextmenu",function(e){
return false;
});

jsFiddle example

Advertisements

One thought on “Disable Right Click on Web Page and Image in ASP.NET

  1. Rahsia Suami Isteri Hebat

    Maaf.. saya berterus terang … walaupun saya kurang bersetuju dengan awak…
    tapi saya akui… pendapat awak memang logik dan pos nih memang menarik..

    Like

    Reply

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