JavaScript: How To Prevent Copy Contents Of Web Sites?



When any user comes to your site or blog then he/she can easily access all the page source, So if you wanna to prevent access to your page contents, then follow these steps:
  • Download javascript file from here.
  • Open it, copy the javascript and paste it in your page from which you want to prevent access.
  • For e.g. you can  check this page source.
  • You can't copy page contents even when you will click on view page source it will display links only.
<script type="text/javascript">
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>

Sharing is Caring

Related Posts

Previous
Next Post »

4 comments

comments
March 10, 2011 at 1:21 PM delete

I just sent this post to a bunch of my friends as I agree with most of what you’re saying here and the way you’ve presented it is awesome.
Best SEO Reseller

Reply
avatar
April 24, 2012 at 11:06 AM delete

hi, thanks for the help, Can u guys give us more detailed step by step how to go about adding this javascript to web page?
thanks

Reply
avatar
April 24, 2012 at 3:29 PM delete

@rainy: paste the javascript on your webpages which you want to prevent from copying.

Like put it on your index page of the site.

Reply
avatar

Thank you for your comment.