Home Article How to Disable Copy Paste in Blogger or WordPress with Simple Method
disble copy paste using html in blogger or wordpress

How to Disable Copy Paste in Blogger or WordPress with Simple Method

0
1975

How to Disable Copy Paste in Blogger or WordPress, Protect your Hard Work

When we write an important article on our web portal, we do write it with very hard work. and someone just copies it and paste it on their own web portal. To avoid this we must take action. We can do it by inserting this javascript in that page.

Copy below given JS code and paste this just above to closing tag of body element i.e. </body>.

This code using jquery so you can use the latest jquery code available.

	<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js' type='text/javascript'></script>
	<script type="text/javascript">
		$(document).ready(function () {
			//Disable cut copy paste
			$('body').bind('cut copy paste', function (e) {
				e.preventDefault();
			});
			//Disable mouse right click
			$("body").on("contextmenu",function(e){
				return false;
			});
		});
		</script>

If you want to protect your whole page then paste above code in between <body> and </body> tag.

Want to Protect a specific part of the page?

To protect only a specific element container, you can use following code for that

<script type="text/javascript">
$(document).ready(function () {
    //Disable part of page
    $('#id').bind('cut copy paste', function (e) {
        e.preventDefault();
    });
});
</script>

Example
If you want to protect an article enclosed with id test12. You’re enclosing your article like this

<div id="test12">
Here is your content that you want to protect
</div> 

then paste this code in between <body> and </body> tag of your theme/template/design and bind your article in between and id like this.
Now your id for this article is test12 then code for this will be

<script type="text/javascript">
$(document).ready(function () {
    //Disable part of page
    $('#test12').bind('cut copy paste', function (e) {
        e.preventDefault();
    });
});
</script>

This will block your article include in your id test12. This code doesn’t affect the speed of your site as there will be no render-blocking due to this js code.

These codes can be used in Blogger, WordPress etc.

How you look at this article ?. If you face any problem implementing this js or not working please comment below.

Finally, your page code will look like for Full Page Copy Page Protection will be

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Document</title>
</head>
<body>
	<main>
		<article id="content1">
<header>
	<h1>This is a sample article</h1>
</header>
<h2>This is subheading of sample article</h2>
<p>This is paragraph of sample article.</p>
		</article>
	</main>
	<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js' type='text/javascript'></script>
	<script type="text/javascript">
		$(document).ready(function () {
			//Disable cut copy paste
			$('body').bind('cut copy paste', function (e) {
				e.preventDefault();
			});
			//Disable mouse right click
			$("body").on("contextmenu",function(e){
				return false;
			});
		});
		</script>
</body>
</html>

and your code for a specific part of the page will look like this.

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>Document</title>
</head>
<body>
	<main>
		<article id="content1">
<header>
	<h1>This is a sample article</h1>
</header>
<h2>This is subheading of sample article</h2>
<p>This is paragraph of sample article.</p>
		</article>
	</main>
	<aside>
		<p>I'm free, you can copy me.</p>
	</aside>
	<script src='https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js' type='text/javascript'></script>
	<script type="text/javascript">
		$(document).ready(function () {
			//Disable cut copy paste
			$('#content1').bind('cut copy paste', function (e) {
				e.preventDefault();
			});
			//Disable mouse right click
			$("body").on("contextmenu",function(e){
				return false;
			});
		});
		</script>
</body>
</html>

By this way, you can protect your pages from being copied but this is not the safest way to do as one can disable JS and can copy but better than content is available for direct copy-paste.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.