17 November 2008

How to disable text selection on Blogger blog

In one of the previous publications, we presented a way 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)
* 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>

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...