How to protect the content from copying?

Protect your website from copying your content

In particular, if your content and images are of a sensitive nature, you should protect your content. There are several ways to ban copying of content – some nasty, some easier. You decide what you choose.

Switch off the "Copy" function using the right mouse button.

In this method, add an attribute below in tag <body …>:

				
					oncontextmenu="return false;"
				
			
After this command, the context menu with the “Copy” option will no longer appear and in this way it will no longer be possible to copy your content. A minus, of course, is that other functions of the menu, such as “Open in a new window”, are no longer possible. However, experienced users can save the text with the keyboard shortcut “Сtrl+C” and still copy the contents. That’s why I present another method.

Forbid marking the text

To prohibit the text from being taggable, add the following code in head.php before the closing </head> tag:
				
					<script type="text/javascript">
function disableSelection(target){
if (typeof target.onselectstart!="undefined")
    target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined")
    target.style.MozUserSelect="none"
else
    target.onmousedown=function(){return false}
target.style.cursor = "default"
}
</script>
				
			
Then add the second script below in footer, file footer.php before the line <?php wp_footer (); ?>
				
					<script type="text/javascript">
disableSelection(document.body)
</script>
				
			
And now it doesn’t matter how users try to copy your texts, “copy” won’t work anymore. At the same time, you no longer have to disallow context menu with the upper attribute, since there will be nothing left to copy.
You can also add an to all copied elements/texts by having the source copied and writing something else as you wish. To do this, add the code below in file header.php before the closing tag </head> :
				
					<script type="text/javascript">
    function wpguruLink() {
var istS = 'Quelle:'; // 
var copyR = '© onlinemarketing-oberland.de'; // Der Name muss in Klammern sein!
var body_element = document.getElementsByTagName('body')[0];
var choose = window.getSelection();
var myLink = document.location.href;
var authorLink = "<br /><br />" + istS + ' ' + "<a href='"+myLink+"'>"+myLink+"</a><br />" + copyR;
var copytext = choose + authorLink;
var addDiv = document.createElement('div');
        addDiv.style.position='absolute';
        addDiv.style.left='-99999px';
        body_element.appendChild(addDiv);
        addDiv.innerHTML = copytext;
        choose.selectAllChildren(addDiv);
        window.setTimeout(function() {
            body_element.removeChild(addDiv);
        },0);
    }
    document.oncopy = wpguruLink;
</script>
				
			
If the text is now copied from your website and saved in another place, the information you have given will also be copied. Don’t forget to change your name on line 4 as well.

Plugins

Plugins have more setting options if you want to go into more detail. You could e.g. For example, only copying texts from posts or receiving messages or sound signals when copying is prohibited. Some of the most popular plugins include Secure Copy Content Protection and Content Locking & WP Content Copy Protection & No Right Click.

I hope now you have a better idea and were able to choose one of the methods.

Table of content

Author M. A. Veronika Keiner
I have been working in the marketing field since 2012. In 2019, due to increasing digitization, I trained as an online marketing specialist and since then I have enjoyed the work a lot. Web design & SEO inspire me a lot! I will be happy to help you with many interesting ideas, advise you and implement your desired design. I look forward to your project!
WordPress Cookie Notice by Real Cookie Banner