Thursday, June 5, 2014

How To Disable Text Selection In Blogger And Other Websites


  • In your dashboard, go to Layout and then click on Add a Gadget.
  • Select HTML/JavaScript


    Copy and paste this code below:



        <script type="text/javascript">

        /***********************************************
        * Disable select-text script- © Dynamic Drive (www.dynamicdrive.com)
        * This notice MUST stay intact for legal use
        * Visit http://www.dynamicdrive.com/ for full source code
        ***********************************************/

        //form tags to omit in NS6+:
        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>     



  • Then save the widget and you’re done.

If you want to disable text selection on other websites then copy the script and paste it into html coding.


Go ahead and try selecting any text on your page. You’ll see that you won’t be able to highlight anything, not even the images for that matter.

No comments:

Post a Comment