Get Latest Tweaks via Facebook, Twitter, Google+ & FeedBurner
    Subscribe:
    Subscribe Twitter Facebook

    Saturday, December 22, 2012

    Disable text selection to prevent users from copying your content

    SOCIALIZE IT →

    Prevent user from copying your content easily

    You must have felt At some point of time, that you needed to disable text selection on your blog or website to prevent others from copying your content. Disabling Text Selection will prevent other from copying text from your page.

    This is just a simple Javascript you need to install on your blog or website.


    How to Install This script to your blog or website:


    You just need to copy below code snippet and paste it just before </head> tag in your page.

    <script type="text/javascript">
    
    /***********************************************
    * script by: http://www.cybertweaks.com/ 
    ***********************************************/
    
    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}
    target.style.cursor = "default"
    }
    
    disableSelection(document.body)
    
    </script>
    

    you're Done.


    0 comments:

    Post a Comment