Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Restrict right click
07-22-2007, 11:10 PM
Post: #1
Restrict right click
Hi guys

i want to restrict right clicking in my web page can anyone help me out with a Javascript for this........
Find all posts by this user
Quote this message in a reply
07-23-2007, 11:58 AM
Post: #2
RE: Restrict right click
Hi Kannan

You can restrict right click on your web page or protect your source code by using this script.
Customize your message"Function Disabled"....But disabling right click is not a complete solution to save the data..

Use following Java scripts.

<script language=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("alert(message);return false")
</script>
Find all posts by this user
Quote this message in a reply
07-23-2007, 09:43 PM
Post: #3
RE: Restrict right click
Just add the following line to the body tag.

PHP Code:
oncontextmenu="return false;" 

Eg:

PHP Code:
<body oncontextmenu="return false;"

This would disable the right click.
Find all posts by this user
Quote this message in a reply
06-10-2013, 03:35 PM (This post was last modified: 06-14-2013 08:47 AM by albinjoseph.)
Post: #4
RE: Restrict right click
You can use the following code to disable right click on a web page:

<sCRIPT language=JavaScript>

var message = "function disabled";
function rtclickcheck(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 = rtclickcheck;
</sCRIPT>
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  restrict copying picture(photo) bpsujith 1 2,466 09-18-2007 06:09 PM
Last Post: albinjoseph

Forum Jump:


User(s) browsing this thread: 1 Guest(s)