Copy Paste Restriction Using Java Script .

Chikul
Posted by Chikul under JavaScript category on | Views : 3910
Restriction of Mouse Right Click and estriction of CTRL Key press.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Copy Paste Restriction Using Java Script . Restriction of Mouse Right Click and estriction of CTRL Key press.</title>
<script language="javascript" type="text/javascript" >

// This function is responsible for the Restriction of Mouse Right Click .
function fnNoRightClick(event)
{
if (event.button==2)//For right click
{
alert("Right Click Not Allowed!");
}
}

// This function is responsible for the Restriction of CTRL Key press .
function fnNoCTRLKey(event)
{
var code = (document.all) ? event.keyCode:event.which;
if (parseInt(code)==17) // This is the Key code for CTRL key
{
alert("Sorry, this functionality is disabled.");
}
}

</script>
</head>

<body>
<form>
<strong>
<asp:Label ID="Label1" runat="server" Text="Copy / Paste Not Allowed"></asp:Label></strong><br>
<input type="text" value="" onmousedown="fnNoRightClick(event)" onkeydown="fnNoCTRLKey(event)"/>
</form>
</body>
</html>

Comments or Responses

Login to post response