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.

Width = 150px Height = 127pxcopy-text

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>

  • 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>

  • 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’>

  • 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>

  • 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.

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.


If you found this post useful, leave a comment and share your thoughts with others.
Get future posts in your RSS feed or by email.


16 Comments

  1. Sorry forgot to mention, you can do this also by going to layout -> HTML look for </body> and add the script just above the </body> tag.  This is better also because gadgets tend to slow your blog down.

  2. I had already done that sis 🙂 and it works fine! m glad u too wrote a code for it 🙂 will surely help a lot as always

  3. @Beth, thanks for that tip. I see you blocked all text selection on your blog. Nifty clinging plants on the edges of your pages! 😎

  4. Yup. Sometime we need to protect our work but sometime we need just let it go. Just share to the world 😉

  5. Thanks for stopping by. Let me know how your new domain works out. Your grab button is very attactive and I see you have your alt= text ! Now you can do a Google search to see who has it.

  6. Glad you pointed out that side of the discussion. Many people can't be bothered and just see it as a compliment to their work or sharing happiness somewhere in the world. Even 'scoundrels' are people, just driven to do desparate things. Their readers can still get something good while the content thieves will one day get what they deserves….

  7. Again, this comment system is not giving me your url and name. Please edit the 'guest' field and sign in with name/url. Glad you were able to use the code!

  8. Excellent, excellent excellent!
    After visiting many other sites.. yours was the first code that actually worked!

    • Very true. It just stops the novice copier. Hopefully those who copy entire articles get caught in Google’s net. Also easier for author to find their sites and report the illegal copying to the webhost. Thanks for stopping by.

Comments are closed.