Disable Text Copying by Content Thieves

Recently a reader asked me to help him prevent anyone from copying text on his blog. The method involves disabling the text selection function. If you can't select text, you can't copy and paste. While this approach is not the answer to content scraping, it can be a first level deterrent. This tutorial is probably more useful to owners of poetry and original storytelling blogs. Expect to catch only the less sophisticated scoundrels. The more experienced ones will use your RSS feed directly. Read more about how to find and fight content thieves.

I'll show you how to disable text copying. The first way is freezes all text on your blog. The second acts on just the post content --- in case you need to keep the sidebar open for a grab my button scroll box.

A. Freeze All Text Selection
  1. Go to your Blogger Dashboard, Layout, Page Elements, Add a Gadget.
    Copy and paste this code, preview and save if no errors.
    <script type="text/javascript">
    /***********************************************
    * Disable Text Selection script- &#169; Dynamic Drive DHTML code library (c)
    * 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}
    target.style.cursor = "default"
    }
    disableSelection(document.body) //Disable text selection on entire body
    </script>
  2. View your blog to test that all copying is disabled. You're done. But do leave a comment on this post!

B. Freeze Post Content Only
  1. Go to your Blogger Dashboard, Layout, Page Elements, Add a Gadget.
    Copy and paste this code. Preview and save if no errors.
    <script type="text/javascript">
    /***********************************************
    * Disable Text Selection script- &#169; Dynamic Drive DHTML code library (c)
    * 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}
    target.style.cursor = "default"
    }
    disableSelection(document.getElementById("mydiv")) //Disable text selection with id="mydiv"
    </script>
  2. Go to Layout, select Edit HTML and back up your template ('download full template')
    Press Ctrl + F to find this line in the template code:
    <div class='contentwrapper'>

    Copy and paste these three lines underneath the line you found.
    <!-- 6/28/09 disable copy of posts only id-'mydiv' -->
    <div id='mydiv'>
    <div id='content'>
  3. Stay at that spot in the template, find these two lines in the html code: (Ctrl + F on the text of the first line in green)
    </b:section>
    </div>

    Copy and paste this code after the second line in green ----to close the id= 'mydiv' tag at the end of post content:
    <!-- 6/28/09 disable copy of posts end div -->
    </div>
  4. Then preview. If there are errors, press the "Clear Edits" button at the bottom of the html edit screen. Otherwise, save your changes. View your blog to test that copying is disabled only on the posts. You're done. But do leave a comment on this post!
If you have trouble leave a comment with your blog address.

spider logo

If you like the posts here, get them for free in your RSS feed or by email delivery. Speaking of buttons, be sure to grab the one in the sidebar to tell your friends about BPWebNews, share the luv.



Print this post