How to disable text selection on web page

Posted by Unknown 0 comments
How to disable text selection on Blogger blog

Learn How to disable text selection on Blogger through this tutorial.In one of the previous publications, we presented a post on how to disable right click on the page of your Blogger blog to decrease the copyright violations from your readers “borrowing” your content for their own purposes. To go further in your content safeguarding efforts, you can make the next step, disabling text selection on your page entirely.

This hack was created by Dynamicdrive as well in the form of Javascript, and is also applicable to those bloggers who don’t like their content copied by others. If this concern is on top of your priorities list, then Copy the following code and Paste it to your blog template:


//<script type="text/javascript">

/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
genuinecontent.blogspot.com
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
target.style.MozUserSelect="none"
else //All other route (ie: Opera)
target.onmousedown=function(){return false} How to disable
target.style.cursor = "default"
}

//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"

</script>//