html tutorials web design help css tutorials free web graphics diy search engine optimization

No Copy and Paste Script

Did you know that you can disable the copy and paste function on your web pages? Of course you did, that's why you're here, to see how it's done. Call me a cwazy wabbit for asking.

This little JavaScript snippet will prevent someone from highlighting your text and using the copy function to copy it and rip it off. It also prevents them from using Ctrl + A to select all the text, or using the right-click menu to Select All. Go ahead, try to copy the text on this page . . . I'll wait.

Of course, since it is JavaScript, it doesn't work if the visitor has JavaScript disabled or has a browser that doesn't support JavaScript. That isn't very many users, but anyone with some experience would know a way around this trick. It will stop most new users though, and at least make it harder for everyone else. That may be all the discouragement they need to move on to easier pickings.

The Howdy Doody of it

Just add the following code to the HEAD tag of your web page:
<script type="text/JavaScript">
//courtesy of BoogieJack.com
function killCopy(e){
return false
}
function reEnable(){
return true
}
document.onselectstart=new Function ("return false")
if (window.sidebar){
document.onmousedown=killCopy
document.onclick=reEnable
}
</script>

Good thing that's a short bit of code to type isn't it, since you can't copy and paste from this page where the code is being demonstrated? Just kidding—if you view the source code you can copy and paste it from there.

Has anyone seen my muse?

Note: By combining this no-copy-and-paste code with a no right-click script you'll add another layer of difficulty for those trying to steal your text. Use my HTML Code Protector to make it as difficult as possible for someone to steal your content. Be warned though, a savvy and determined user can still figure out ways around all the protection, nothing is perfectly safe on the Internet. Fortunately, not many people want to spend that much time at it when it's much easier to go steal from someone else.

Also: This script may not work in all browsers. It does work in Internet Explorer and Firefox, which comprises the overwhelming majority of users.

Back | Web Design Tutorials Index
Cheap Web Hosting

Ezine for Webmasters

Bookmark and Share

Almost a Newsletter

Subscribe today and get a free gift, The Science of Getting Rich. Learn more, or subcribe below:
Email:

First Name:

Privacy Policy

Did you know...

The member's site has about 100 standards compliant HTML and CSS tutorials, 31 handy reference charts, reprintable content, web graphics, exclusive fonts, free software, free ebooks and more? All this for less than 9 cents a day! [ Details ]
See my fancy bottom! :)