Friday, March 18, 2005

Disable Control+C in javascript

How to disable control+C in your web page to prevent user simply copy your text? Here is the code:-


<html>
<head>
<script language="javascript">
<!--
function Disable_Control_C() {
var keystroke = String.fromCharCode(event.keyCode).toLowerCase();

if (event.ctrlKey && keystroke == 'c') {
event.returnValue = false; // disable Ctrl+C
}
}
//--!>
</script>
</head>
<body onkeydown="javascript:Disable_Control_C()">
Hello World!
</body>
</html>

NOTE: You may need to disable the right click and menu bar to prevent user to copy from your text.

7 comments:

Anonymous said...

Hi NG Yew Ban. I've been looking for computer software information and came across your site. I was really after computer software related info but I came across your site and found it a good posting even though this post was'nt exactly what I was after. Thanks for the read

Anonymous said...

Hello NG Yew Ban. I was looking for some information on discount software and came across your site. Not really what I was after but I found it very interesting. I was looking for discount software related information. Glad I found your site even though it was not exactly what I was after. Keep up the good posting - thanks

Anonymous said...

Hi NG Yew Ban. I've been looking for software downloads information and came across your site. I was really after software downloads related info but I came across your site and found it a good posting even though this post was'nt exactly what I was after. Thanks for the read

Anonymous said...

Our site Sri Lanka Hotels was looking for a solution to disable crtl+copy and a way to disable the right click. We found what we were looking for here - Thanks you.

Δημήτρης said...

Hi

I have put this code to my blog and it doesn't work...

chaitanya said...

It doesn't work

Allan said...

IT companies are gaining popularity with every passing day and tend to grow at a rapid speed. Software development company procedures are getting purifies and verified with a brilliant merge of existing and new technologies everyday. Due to the massive demand of automation and perfection, many organizations are now opting outsourcing software development in order to meet their business needs.