How to disable Copy, Paste and Text Selection using CSS

4/04/2014 1 Comment

Disable Copy/Paste and Text Selection using CSS and Javascript.

CSS Code to disable text selection and highlighting.

This CSS code will disable text highlighting and selecting for your website/blog post. This CSS code works perfectly in Internet Explorer, Mozilla Firefox and Google Chrome. In blogger you may put the code inside the .post-body section.
-webkit-user-select: none;
-khtml-user-drag: none;
-khtml-user-select: none;
-moz-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
One thing to note about the above CSS code is that in Firefox, it will also disable Copy/Paste of the content of your post/website. However, the copy will still be possible in Chrome browser.

CSS Code to enable text selection in Blockquote.

There may be cases where a certain portion of your post may still need the highlighting and selection, let say in the blockquote area where you may write certain sample code. In that case just you need to put
.post blockquote {
-webkit-touch-callout: text;
-khtml-user-select: text;
 -moz-user-select: text;
 -ms-user-select: text;
 user-select: text;
 -o-user-select:text;
 -webkit-user-select: text;
}

Disable Copy/Paste of you content.

To disable copy/paste in the blogger and Wordpress posts copy the below code into you theme template. This will make the task of copying text a little complex for content scrappers.
<script type='text/JavaScript'>
function killCopy(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function (&quot;return false&quot;)
if (window.sidebar){
document.onmousedown=killCopy
document.onclick=reEnable
}
</script>

1 comment :

  1. Solved the problem in my blog. Many had copied the contents without permission

    ReplyDelete

 

Aired | The content is copyrighted and may not be reproduced on other websites. | Copyright © 2009-2016 | All Rights Reserved 2016

Contact Us | About Us | Privacy Policy and Disclaimer