If you want to disable Right Click in your web pages, use this java script in your web page.
<script language="JavaScript"> var message = 'Right Click is disabled';
function clickIE() { if (event.button == 2) { alert(message); return false; } }
function clickNS(e) {
if (document.layers || (document.getElementById && !document.all)) {
if (e.which == 2 || e.which == 3) { alert(message); return false; }
}
}
if (document.layers) { document.captureEvents(Event.MOUSEDOWN); document.onmousedown = clickNS; }
else if (document.all && !document.getElementById) { document.onmousedown = clickIE; }
document.oncontextmenu = new Function('alert(message);return false') </script>
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Hitesh chotaliyaPosted Jun 25, 2018, 6:17 AM
MVC Inside object not working, Pdf viewer object not working
Nithish ReddyPosted May 23, 2018, 6:38 AM
Sir ! how to restrict in a pdf file ?
Blocked AccountPosted Mar 14, 2013, 6:48 AM
Pankaj, If you disable the javascript, then this script will not work.
Pankaj PandeyPosted Mar 14, 2013, 6:12 AM
copy and paste this java-script function in Head tags....It will work automatically.... BY http://www.varanasiworld.com/<script type="text/javascript">var message = "Function Disabled!"; function clickIE4() {if (event.button == 2) {alert(message);return false;}}function clickNS4(e) {if (document.layers || document.getElementById && !document.all) {if (e.which == 2 || e.which == 3) {alert(message);return false;}}}if (document.layers) {document.captureEvents(Event.MOUSEDOWN);document.onmousedown = clickNS4;}else if (document.all && !document.getElementById) {document.onmousedown = clickIE4;}document.oncontextmenu = new Function("return false")</script>
Pankaj PandeyPosted Mar 14, 2013, 6:06 AM
can you tell me where this function will call?? and if my web browser 's java script is disabled then how this java-script function will work???
Sonu SinghPosted Dec 30, 2012, 7:57 AM
just copy n paste... It hepls u... http://wwwsonusingh255.blogspot.in/2012/12/right-click-disable-in-aspnet-page.html