How Do I disable the copy paste feature in my webpage. To be precise, I don't want my users to copy any information from my website and use them for personal purposes. The previous question on the same topic doesn't give enough explanation. The onselect and ondrag aren't working. Please help.
-
Hey! yah... I know if ppl don't want to copy my info lemme not put it and stuff..! :P you sounded funny :) they can take screenshots and stuff... but I want to disable copy and paste functionality... thats all... even if they want from viewsource.. let them take it... but not directly from the content... please help :) – 1s2a3n4j5e6e7v Jun 11 '10 at 06:58
-
Please understand that I need a SCRIPT which can disable it... something like unselectable or something... thanks for giving me a vote down..! What I need is A SCRIPT :( – 1s2a3n4j5e6e7v Jun 11 '10 at 07:04
-
1@1s2 The downvote is not mine, but *forget it*. Scripts can be disabled. Your problem is *not* solvable using technical means. – Pekka Jun 11 '10 at 07:07
-
he he..! I din't mean the vote down was yours !PEACE! I just put it to the person who gave this..! I have seen a lot of sites where in you are not given with the functionality of selecting...! thats disabled... if someone was able to do it.. there should be a way... – 1s2a3n4j5e6e7v Jun 11 '10 at 07:10
-
@1s2 Can you show an example? I'm sure somebody will then be able to explain how they do it. – Pekka Jun 11 '10 at 07:45
-
@All: See this site, they have disabled copy-pasting the lyrics. http://goo.gl/kowB Now please explain it how they did this? Thanks! – ivorykoder Oct 11 '10 at 10:59
-
1Possible duplicate of [How to prevent a website being completely consumed and mirror-served elsewhere?](http://stackoverflow.com/questions/1142788/how-to-prevent-a-website-being-completely-consumed-and-mirror-served-elsewhere) – TylerH Mar 15 '16 at 18:06
18 Answers
I don't want my users to copy any information from my website and use them for personal purposes
There is no way to do this. If someone really wants your information, they can get it.
You might be able to give them a litte bit of trouble with disabling certain functions using javascript or whatever...but you'll only give the people who don't know much about technology that trouble. And usually those people aren't even trying to copy your data. The one's who are, will figure out a way.

- 15,401
- 9
- 56
- 75
-
1yeah..! its fine..! how do I give "the people who don't know much about technology that trouble"? – 1s2a3n4j5e6e7v Jun 11 '10 at 07:11
-
1when I was not able to find it by Google, I came to stack overflow. I want specific answer, for answers like these, I could have used Yahoo Answers :P – 1s2a3n4j5e6e7v Jun 12 '10 at 15:06
-
If you publish information online, you should clearly indicate your copyright claim on the page (or indicate the type of license you issue the content under). Please find and read the copyright law of your territory to understand what this does and doesn't allow - for example, in the UK there are provisions for making personal copies of copyrighted material and for using parts of copyrighted work for critical review or parody.
You can't stop people from copying the content on your page. You can make it more difficult for them to do - but this will have a negative impact on your page. Techniques such as preventing the left-click of the mouse, intercepting keyboard events or converting your entire article into images just make your website less usable.
If you have textual information on your website, I can re-type it even if you've stopped every other method of me copying the image. If you have an image and you've managed to lock out everything else, I can still do a screen-grab (not to mention the fact that my browser caches all the images in a temporary folder on my machine).
Your content-paranoia affects many people who set up a website - but the idea behind the Internet is that it is used for sharing information.

- 241,084
- 71
- 387
- 401
Just add the following code to the HEAD tag of your web page:
<script type="text/JavaScript">
//courtesy of BoogieJack.com
function killCopy(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
if (window.sidebar){
document.onmousedown=killCopy
document.onclick=reEnable
}
</script>

- 59
- 1
- 1
By default, Chrome and Firefox block disabling the right click menu. You have to manually edit an entry in about:config in Firefox to prevent it being blocked, which is not something you can force your visitors to do.
Regarding IE, you can modify your BODY tag like so:
<body onContextMenu="return false">
Which will prevent the right click context menu.
Other than that, the next best step is to create an image of your text, place it in a .swf (flash) document, and point the page to load the .swf as the page. This will cause all browsers to display the flash context menu on right click, and will prevent simple copy/paste efforts.
I do agree with previous replies, regardless of method used, any user can simply use their Print Screen key, paste the image in Paint (or other program), save it, and use OCR to grab your text.

- 147
- 9
-
1Even on IE, this only disables right-click menu and only if the user enables blocked contents. However, the user can still highlight text and press Ctrl-C to copy it. – PauliL Jun 11 '10 at 09:19
-
You need to rethink your strategy if you're resorting to these measures on the front end. What you are trying to do is inherently wrong.
As a visitor to your web page, pulling something like this is just going to annoy me - I will eventually figure out what you've done and get around it. That said, I've recently found this particular method can be quite effective if you're aiming to restrict impatient or non-technical users. Proceed with caution...
<div class="text">
<p>Hello, world! Sadly, <a href="#">I won't work</a>.</p>
<img alt="I can't be dragged or saved either :(" src="tree.png">
<div class="preventSelect"></div>
</div>
...and the CSS:
.text {
position: relative;
width: auto; /* can be fixed as well (ie 400px) */
width: auto; /* can be fixed as well (ie 400px) */
z-index: 0;
}
.preventSelect {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
}
The obvious drawback for this method is that the user cannot interact with anything inside the div we're preventSelect
ing. That includes links, buttons, images etc.
Please don't use this unless you absolutely have to. Frankly, it's a pain in the ass for everyone.

- 950
- 1
- 13
- 27
To be honest, if you don't want people to use any information on your site, then you can't put it up there. If you stop them from being able to copy and paste the information, they'll still be able to take a screenshot of it, type it out and save the data that way. I know it's not the answer you're looking for, but that's just something to think about.
(I did this because i can't comment yet).
-
screenshot is fine! but what's it for disabling copy paste! thats what I'm looking for... – 1s2a3n4j5e6e7v Jun 11 '10 at 07:08
Forget it. It is not possible to block these functions in a browser. The "best" you can do is to present your data in an image or Flash movie - inconceivable, slow, impractical, horrible to implement and also circumventable using OCR software.
If all else fails, users will simply make screen shots or key in the data manually.
If you present data to your users, you will have to live with the possibility that they can copy it. End of story.
Use legal threats to prevent your contents, not technical means.

- 442,112
- 142
- 972
- 1,088
-
5and even an image can be sent to an ocr pretty well. Unless the whole page ends up looking like a captcha lol – Dan Heberden Jun 11 '10 at 06:52
What the developers of lyrics.com have done is attach events to document.body.oncontextmenu
, document.onselectstart
, and document.body.onkeydown
to disable the actions browsers would take.
It can be done as simply as
<body oncontextmenu="return false" onselectstart="return false"
onkeydown="if ((arguments[0] || window.event).ctrlKey) return false">
You'd need all three; oncontextmenu
basically governs right clicks, onselectstart
covers drag-selecting with the mouse, and onkeydown
Ctrl-key events (like someone who'd hit Ctrl+A, Ctrl+C to copy the whole page).
But I highly recommend that you NOT DO THIS. It kills usability and frustrates even legitimate users (for example people that have certain key mappings set up, or the ones who use "back" and "reload" from the context menu), and the ones you'd have to worry about would not be hindered even the slightest bit. And frankly, your content is not as special as you think it is, or you wouldn't be serving it up to any loser with a web browser. Information that valuable is not put online.
As has been noted before, all that return false
stuff is not enforceable. And because i found the page particularly infuriating, that prompted me to pop up a console and dissect what they did, and detach event handlers so i could copy whatever i like and they don't even get their precious click-tracking data. Really, though, all anyone has to do is disable JavaScript.
The only way to keep people from copying text from the internet, is to keep it off the internet. Any other way is doomed to fail, as you yourself are handing them a copy as part of the very act of serving it to them.

- 26,799
- 13
- 69
- 83

- 84,970
- 20
- 145
- 172
You can't ever disable it.. users can view the source of your page so the text is always available. If you put click handlers to disable right-click, they can turn javascript off..
The best you can try to do is make it inconvenient for people to deter them, but never can you prevent them.

- 10,990
- 3
- 33
- 29
It is impossible to secure a website against copying. There are some technices to make it more difficult, but as soon as the user has the information on his screen its already too late. He could for example take a picture with a camera if the screenshot function could be disabled somehow.
Disabling of javascript functionality (f.e. shortcuts) is not working in all browsers and the user may disable javascript.
Using programs like curl all the information on the webpage can be grabbed.
Best thing you could do is to put all the information you present into an image.

- 50,002
- 13
- 138
- 166
-
right, but the overhead(+transmission time) to create an image from a dynamic page is huge – Thariama Jun 11 '10 at 08:53
You can stop from copy paste using below code
<body ondragstart="return false" onselectstart="return false">

- 61,146
- 24
- 125
- 222

- 797
- 11
- 22
-
1Please edit your answer to include an explanation why this is such a superior solution and how it solves the problem. Are there any limitations? – Artjom B. Jun 27 '15 at 16:13
-
all above answer do not exactly provide solution to the problem while here i am providing solution to the problem. – The EasyLearn Academy Jul 18 '15 at 17:13
-
1I find that hard to believe, but please add a description why this solves the question. – Artjom B. Jul 18 '15 at 17:15
-
<script type="text/javascript">
function md(e)
{
try { if (event.button==2||event.button==3) return false; }
catch (e) { if (e.which == 3) return false; }
}
document.oncontextmenu = function() { return false; }
document.ondragstart = function() { return false; }
document.onmousedown = md;
</script>
<br />

- 7,275
- 1
- 26
- 19

- 9
- 1
-
Also, I can still type `document.body.innerText` in the developer console or erase your handlers. Even if the dev console was inaccessible, I could go to `javascript:alert(document.body.innerText)` – John Dvorak Jan 02 '14 at 07:11
Try adding this css:
#content {
pointer-events: none;
}
This will deactivate mouse actions, thus copy-paste too.

- 461
- 2
- 10
- 20
Disable cut, copy, and paste options.
<script language="text/javascript">
// disable portal cut copy and paste options.
$('body').bind('cut copy paste', function (e) {
e.preventDefault();
});
</script>
But I prefer to enable this option on localhost.
<script language="text/javascript">
// disable portal cut copy and paste options.
$('body').bind('cut copy paste', function (e) {
// enable only localhost
if (location.hostname === "localhost" || location.hostname === "127.0.0.1")
{
return;
}
e.preventDefault();
});
</script>

- 329
- 3
- 10
please try this one its working for me...
$('body').bind('cut copy paste',function(e) {
e.preventDefault(); return false;
});

- 121
- 1
- 3
With Javascript you can disable copy/cut/drag for average users who don't know how to use inspect element
feature, for that just add this simple javascript code:
document.addEventListener("copy", disable);
document.addEventListener("cut", disable);
document.addEventListener("drag", disable);
document.addEventListener("dragstart", disable);
document.addEventListener("dragover", disable);
document.addEventListener("dragend", disable);
document.addEventListener("drop", disable);
function disable(e) {
if (e) e.preventDefault();
return false;
}
If the user however tries to access the source code then you can't stop him, the best is to wrap each sentence in its own span to make it difficult for him to copy.

- 1,452
- 1
- 17
- 30
<script type="text/JavaScript">
function killCopy(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
if (window.sidebar){
document.onmousedown=killCopy
document.onclick=reEnable
}
</script>

- 9
- 1
- 5
I would suggest disabling right click.
<script language="text/javascript">
var message = "Not allowed.";
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>

- 39,330
- 16
- 106
- 107

- 1