How to disable mouse click and copy paste in HTML – Blogger and WordPress
Disable right-click and Copy Paste in Blogger and WordPress
Why do we need to disable right-click and copy-paste on our blog? Do you know that someone can steal your work and take credit for your work?
You need to protect your work by disabling right-click on your posts and select text option on your blog. But the question is how to disable it? – Don’t worry in this post we will discuss it with source code? Let’s see them in action!
Disable Right Click Using JavaScript
Disable Right Click in Blogger
Disabling right-click in Blogger is very easy, you just need to follow the 3 steps given below:
Step 1. Log on to the Blogger Dashboard and select the blog you want to disable right-click on.
Step 2. Navigate to Layout, click on it and then click on Add new Gadget and select HTML/JavaScript.
Step 3. Copy the JavaScript code below and paste it in opened HTML/JavaScript gadget. Enclose the below JavaScript code with open and close JavaScript code ie.
<script language=javascript>
function blockOne() {
if (document.all) {
return false;
}
}
function blockTwo(e) {
if (document.layers||(document.getElementById&&!document.all))
{
if (e.which==2||e.which==3) {
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.mousedown);
document.onmousedown=blockTwo;
}
else {
document.onmouseup=blockTwo;
document.oncontextmenu=blockOne;
}
document.oncontextmenu=new Function("return false");
</script>
That’s all you are done! Open your page or post and try right-clicking over it. It will not allow you to right-click.
Disable Copy Paste i.e.. Content Copy Protection in Blogger
We can protect our content in Blogger from copying in two ways i.e.. Using CSS and Using JavaScript
Using CSS
We can protect Blogger content from copying in 3 steps:
Step 1. Log on to Blogger Dashboard
Step 2. Navigate to Theme > Customize > Edit HTML
Step 3. Find ]]></b:skin> and just before this paste the given below
Body {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
Step 4. And finally Save changes that’s all you are done!
Using JavaScript
Log on to Blogger Dashboard > Theme > Customize > Edit HTML
Find the </body>, just before closing body tag paste the JavaScript code below:
<script>
$('body').bind('copy cut drag drop', function (e) { e.preventDefault(); });
</script>
Save changes that’s all your work is done. Now no one can select your text for copying.
Disable Copy Paste in WordPress
Log on to WordPress Dashboard and then navigate to Appearance > Customize > Additional CSS and paste the code given below:
Body {
user-select:none;
}
Disable Right Click On WordPress Website or Blog
In WordPress you are not required to write a single line of code. You can disable right click on WordPress blog or website just by installing any one of the following plugins:
- WP Content Copy Protection & No Right Click
- Disable right-click for WordPress
- No Right Click Images plugin
Conclusion
Finally, I explained How to disable mouse right click and copy paste methods in Blogger as well as WordPress with source code. I hope it will help you, if any query you have regarding this let me know in the comment or you can mail me at karunasingh@blogearns.com