Reputation: 479
I'm trying to ignore Ctrl-C in my website but im stuck.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript">
function whichButton(event)
{
if (event.button==2)//RIGHT CLICK
{
alert("Not Allow Right Click!");
}
}
function noCTRL(e)
{
var code = (document.all) ? event.keyCode:e.which;
var msg = "Sorry, this functionality is disabled.";
if (parseInt(code)==17) //CTRL
{
alert(msg);
window.event.returnValue = false;
}
}
</script>
</head>
<body>
<form method="">
<strong>Not Allow Paste </strong><BR>
<input type="text" value="" onMouseDown="whichButton(event)" onKeyDown="return noCTRL(event)"/>
</form>
</body>
</html>
I tried this code, but it is can only ignore right click.
How can I ignore Ctrl-C?
Upvotes: 3
Views: 1113
Reputation: 731
Have a look at this website
But if someone wants to copy your content, they can. It will just make it harder and more time consuming to use.
Regarding this Ctrl-C you could add javascript to block it, but it is useless, since the user can always disable javascript. In fact many users will find interception of right-click very annoying.
All these could have a meaning if you are building an intranet application or you can ship an integrated browser for users to view the application. With public html, I believe it isn't even worth trying. One solution would be to build your application with flash or another plug-in. This way you can encrypt everything you've sent to the client.
Upvotes: 2
Reputation: 8951
if your body tag adds these events
<body oncontextmenu="return noMenu();" onkeydown="return noKeys(event);">
and you then define these functions in your <head>
section, you can take action when the context menu is activated (right click) or when keys are pressed on your page.
<script type="text/javascript">
function noMenu()
{
alert("Not Allow Right Click!");
return false;
}
function noKeys(event)
{
if (event == null) event = window.event;
// here you can check event.keyCode
return false;
}
</script>
Upvotes: 1