How to Disable Text Selection in Blogger Blogs Using Javascript & CSS

Disable Text Selection in Blogger Blogs Using Javascript & CSS - techfirex

How to Disable Text Selection in Blogger Blogs Using Javascript & CSS

Hello, friends in this article we are going to learn about how we can disable text selection in blogger.
Here I've two methods for that one is using CSS codes and the second is using JavaScript codes.

I recommended using method one (using CSS codes) because this is not much affecting on your blog posts speed but javascript codes slow down your page load speed and also note that if blog reader disables javascript in their browser then they can easily select the text and copy it but in case of CSS remain safe.

How to Disable Text Selection in Blogger Using CSS:

First, go to your blogger and open it.
Then go to Themes >> Edit HTML option.
Here press CTRL + F and find ]]></b:skin>
Just before this ]]></b:skin> code copy and paste the codes provided below.

The codes below are allowing readers to copy the important codes on a blog while disallowing them to copy all the text. The codes below are important for those bloggers who are having a tutorial niche like this blog.
.post blockquote{-moz-user-select: text;-webkit-user-select: text;-ms-user-select: text;user-select: text;}
.post code {-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text;}
body {-webkit-user-select: none; -moz-user-select: -moz-none; -ms-user-select: none; user-select: none;}
Note: If it’s not necessary for you to allow your audience to copy some of your text you may put only the codes below. (Means Disable whole posts text selections including codes and blockquotes etc then use the below code and paste it there)
body {-webkit-user-select: none; -moz-user-select: -moz-none; -ms-user-select: none; user-select: none;}

How to Disable Text Selection Using JavaScript:

This easy then CSS codes implementation because of adding javascript but as I earlier said this is easily bypassed by post readers.
Go to your blogger dashboard.
Click on the layout option and add a gadget and select HTML/JavaScript.
Now copy the below code and paste it there and save it.

Note: The codes given below will automatically disable text selection including the Blockquotes and Codes.
<script type=”text/javascript”>
//form tags to omit in NS6+:
var omitformtags=[“input”, “textarea”, “select”]
omitformtags=omitformtags.join(“|”)
function disableselect(e){
if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
return false
}
function reEnable(){
return true
}
if (typeof document.onselectstart!=”undefined”)
document.onselectstart=new Function (“return false”)
else{
document.onmousedown=disableselect
document.onmouseup=reEnable
}
</script>