Disable copy / paste on a web page

How to disable the copy function in my web page. To be precise, I do not want my users to copy any information from my site and use it for personal purposes. The previous question on the same topic does not provide sufficient explanation. Onselect and ondrag do not work. Please, help.

+6
source share
15 answers

I do not want my users to copy any information from my site and use it for personal purposes

There is no way to do this. If someone really wants your information, they can get it.

You may be able to give them a small problem with disabling certain functions using javascript or something else ... but you will give people who know little about technologies that bother. And usually these people do not even try to copy your data. The one who will figure out the way.

+22
source

If you publish information on the Internet, you must clearly indicate your right to receive copyright on the page (or indicate the type of license under which you send the content). Please find and read the copyright law on your territory to understand what this does and does not 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 view or parody.

You cannot prevent users from copying content on your page. You can make it harder for them - but it will have a negative effect on your page. Techniques such as left-clicking, capturing keyboard events, or converting an entire article to images simply make your site less useful.

If you have text information on your website, I can reprint it, even if you stopped any other way of copying the image. If you have an image and you managed to block everything else, I can still take a screen capture (not to mention the fact that my browser caches all images in a temporary folder on my machine).

Your content paranoia affects the many people who created the website, but the idea of ​​the Internet is that it is used to exchange information.

+7
source

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> 
+4
source

By default, locking Chrome and Firefox disables the right-click menu. You must manually edit the entry in about: config in Firefox to prevent it from being blocked, which is not something you can get your visitors to do.

As for IE, you can change your BODY tag as follows:

 <body onContextMenu="return false"> 

This will prevent the right-click context menu.

In addition, the next best step is to create an image of your text, place it in a .swf (flash) document and specify the page to load .swf as a page. This will force all browsers to display the flash context menu with a right-click and will prevent the simple copy and paste efforts.

I agree with the previous answers, regardless of the method used, any user can simply use their Print Screen, paste the image into Paint (or another program), save it and use OCR to capture your text.

+3
source

You need to rethink your strategy if you resort to these measures on the front side. What you are trying to do is inherently wrong.

As a visitor to your web page, pulling something like this will just annoy me - I will eventually find out what you did and get around it. However, I recently found this particular method can be very effective if you want to limit impatient or non-technical users. Be careful ...

 <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 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 of this method is that the user cannot interact with anything inside the div, which we preventSelect ing. This includes links, buttons, images, etc.

Please do not use this unless you absolutely need to. Honestly, this is a pain in the ass for everyone.

+3
source

To be honest, if you do not want people to use any information on your site, then you cannot express it there. If you stop copying and pasting information, they can still take a screenshot, print it, and save the data in this way. I know that this is not the answer you are looking for, but it is just something to think about.

(I did this because I cannot comment yet).

+2
source

Forget about it. It is not possible to block these functions in the browser. The β€œbest” thing you can do is present your data in an image or in a Flash movie β€” it is unthinkable, slow, impractical, terrible to implement, as well as circumvent using OCR software.

If all else fails, users simply take screenshots or enter data manually.

If you present data to your users, you will have to live with the ability to copy it. The end of the story.

Use legal threats to prevent your content, not technical means.

+2
source

Unable to protect the site from copying. There are several techniques that make work difficult, but as soon as the user has information on his screen, it is too late. He could, for example, take a picture with the camera if the screenshot function can be disabled in some way.

Disabling the javascript function (e.g. shortcuts) does not work in all browsers, and the user can disable javascript.

Using programs such as curl, all information on a web page can be captured.

The best thing you could do is put all the information you represent in the image.

+1
source

What song.com developers have done is attach events to document.body.oncontextmenu , document.onselectstart and document.body.onkeydown to disable browser actions.

This can be done in the same way as

 <body oncontextmenu="return false" onselectstart="return false" onkeydown="if ((arguments[0] || window.event).ctrlKey) return false"> 

You will need all three; oncontextmenu mainly controls right-clicks, onselectstart covers mouse-dragging and onkeydown Ctrl-key event (for example, the one who hit Ctrl + A , Ctrl + C to copy the entire page).

But I highly recommend you DO NOT DO IT. . It kills usability and upsets even legitimate users (for example, people who have certain key mappings, or those who use "back" and "back", reload "from the context menu), and those that you have to worry about, they won’t interfere with even the smallest bit, and frankly, your content is not as special as you think, or you won’t serve it to any loser using a web browser. Information that is valuable is not posted on the Internet.

As noted earlier, everything that return false cannot be executed. And since I found the page to be particularly annoying, it prompted me to open the console and analyze what they did and separate the event handlers so that I could copy whatever I like and they don’t even get their precious click tracking data. In fact, all you have to do is disable JavaScript.

The only way to keep people from copying text from the Internet is to disconnect it from the Internet. Any other method is doomed to failure, because you yourself give them a copy as part of the action itself, serving them for them.

+1
source

You can never disable it. Users can view the source of your page so that text is always available. If you place clicks to disable right-clicking, they may disable javascript.

The best you can try to do is make it inconvenient for people to hold them back, but you can never prevent them.

0
source
 <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 /> 
0
source

You can stop copying using the code below

 <body ondragstart="return false" onselectstart="return false"> 
0
source

Try adding this CSS:

 #content { pointer-events: none; } 

This deactivates mouse actions, so copy and paste too.

0
source
 <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> 
-1
source

I would suggest disabling the 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> 
-2
source

Source: https://habr.com/ru/post/1415084/


All Articles