Block the Right Clicking on page

You can block right clicking on your page. By this feature you can ensure that no one see your client side code by view source. And if you don't want that no one make copy of your page content then this will be helps you.
Normally if you make right click on web page then you can see that there are many options comes. In these option, the view source option is one of them. By this option you can see hole structure of your web page (like designing part) and you can also see the script part which will be use on that page.
So if you want to block all the options of page then you can use this line of code in tag in your page:

Body onContextmenu="return false"

By this single line of code , the right clicking becomes block.


Author: guru prasad20 Jan 2009 Member Level: Gold   Points : 1

This code is not working...

can you provide the technique with more explanation...

Also we can see the source code of the page using browser window tools menu. so how can we protect our code not to expose...

Thaning you...

Author: Narayanan S21 Jan 2009 Member Level: Bronze   Points : 1

I have tried the same code in ASP.NET(C# code) and it is working properly.
body MS_POSITIONING="GridLayout" oncontextmenu="return false"


Author: Tarak02 Feb 2009 Member Level: Bronze   Points : 0

Not working...

Author: Kusum10 Feb 2009 Member Level: Bronze   Points : 0

Thx a lot....

It realy help me.

Thx & regard


Author: shaikabbas06 Apr 2009 Member Level: Gold   Points : 0

try this

body MS_POSITIONING="GridLayout" oncontextmenu="return false"

Author: subhashinichoudhary30 Nov 2009 Member Level: Gold   Points : 1

ok its working properly you are right.but the source code will be opened from Browse....>Menu....>View....>Sourcecode.

Author: Sachin Kumar21 Dec 2009 Member Level: Gold   Points : 1

source code can also be opened from Browse....>Menu....>View....>Sourcecode
Please also suggest to block this option.

Author: Prakash kumar pothal18 Feb 2010 Member Level: Gold   Points : 2

Add this below code in ur javascript for Block the Right Clicking on page .if u have used the master page than put this code in the master page.Its working in all the pages if pages are inherited from the master page

This code is wokring on both for IE and FF.

var message = "function disabled";
function RightClickCheck(keyp) {
if (navigator.appName == "Netscape" && keyp.which == 3) { alert(message); return false; }
if (navigator.appVersion.indexOf("MSIE") != -1 && event.button == 2) { alert(message); return false; }
document.onmousedown = RightClickCheck;


Author: Developer18 Feb 2010 Member Level: Gold   Points : 1

hi prakash,

it is not worked in IE.

only its working only in FF.
can u explain me why.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: