-->

Tuesday 26 April 2016

How To Disable Copy & Paste Function In Blogger With CSS or JavaScript



Most of the real bloggers faced using blogspot are face with the problem of their content on their blogs being copied or duplicated by novices who are just entering into the blogosphere with the objective of making money without making real efforts and understanding of the value of the original / unique content. Sometimes the contents copied by them gets a higher ranking in search engines than your original content, and this is unfair, which lowers the motivation of real bloggers.



It is important to protect your blog content from these content thieves and this is the agenda of this post. We will disable the copy function by disabling the mouse right click and CTRL + A. We have two options to do so,i.e through a JavaScript code if you want full text field blog or via CSS code switch if you share some codes / text on your blog posts and your readers need to copy them.



Disable Text Selection Blogger With JavaScript code



Go to Blogger Template → → → Edit Template Backup your Template Code First.

Now search for and copy and paste the JavaScript code below after the tag.
Data
(Note: - Use Ctrl + F in Windows and Cmd + F to search Mac to code template)



<!--Disabe Copy Paste--- TB-->


<script language='JavaScript1.2'>


function disableselect(e){


return false


}


function reEnable(){


return true


}


document.onselectstart=new Function (&quot;return false&quot;)


if (window.sidebar){


document.onmousedown=disableselect


document.onclick=reEnable


}


</script>




Now save your template and view your blog to check out the results.





Disable Text Selection Except Specified Codes/Text With CSS




This is the magic code that we use on this blog, because we share tutorials where readers have some codes that we share, as copy CSS / JavaScript / HTML etc. So at the same time we do not let the readers to copy our posts "other than codes / text we want to share. This is possible with this simple CSS code where we could use the copy-paste the text / code we put in "blockquotes" only. Go to Blogger Template → → Edit Template → Backup.

Search Now]]> this code line and copy and paste given the CSS code below this]]> tag line

(Note: - Use Ctrl + F to search in Windows and Cmd + F on Mac in template code)



/ * ----- Disable Text Selection with CSS TB --- ---- * /

.post blockquote {

-webkit-user-select: text important;
!
-moz-user-select: text important;
!
-MS-User-select: text important;
!
user-select: text important;
!
}

body {

-webkit-user-select: none important;
!
-moz-user-select: none -moz-important;
!
-MS-User-select: none important;
!
user-select: none important;
!
}


Important note: - In the above CSS code we've activated the copy / selection text / we post with blockquotes code that .post blockquote but it may not work for you if your template is using different CSS class for blockquote for example our template using .post blockquote where your template could be using .post-body blockquote or blockquote. So in that case you need to replace .post blockquote with .post-body blockquote blockquote above or CSS code. If you have no share codes or content then just copy and paste this little piece of CSS code to disable all text area on your blog.



/ * ----- Disable Text Selection with CSS TB --- ---- * /

body {

-webkit-user-select: none important;
!
-moz-user-select: none -moz-important;
!
-MS-User-select: none important;
!
user-select: none important;
!
}


Note :. You can add CSS code by just going to the Template Designer >> Add custom CSS and paste then save the code



The Advantage Of Using CSS Instead Of JavaScript?



1) If we use JavaScript code, you know what does a copy cat do? They Simply enable JavaScript in their browser and reload the page. Then everything goes back to its normal format and he can copy the whole con tent on your blog.



Using CSS we eliminate this factor as user usually cannot eliminate the CSS. Yet, an experienced user can do by simply inspecting elements and finding our CSS code snippet then remove the browser, but this task is far from newbies. Experienced users rarely do so.



2) CSS codes are much better than Java Scripts because it does not reduce the speed of your blog / website while JavaScript codes consume a lot of time to load and make your blog load speed to be very low and the total loss of your Visitors = Money. Avoid using JavaScripts.



Let us know where these codes work for you if you have problems with these codes? We will help you out. Thank you.
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post
 

Delivered by FeedBurner