How to protect your website content
- hints and tips
- June 11, 2011
- 0 Comments
loading...
This little tutorial covers how to prevent people from using simple techniques to steal your website text and images – please note that this is by no way a bulletproof way of protecting your website content, there are ways around this system but it will stop the casual copy ‘n paste visitor…
You will need FTP access to your website and you will need to be comfortable editing files (either .html or .php etc)
The first step is to disable “right click” as this is the most common way to grab images from a webpage:
You will need to edit each page that you want to protect if your website is HTML based or if you are running a script such as a Blog or a CMS system then you should be able to get away with just editing either the index.php file or the main template file(s)
The following code needs placing at the top of the <BODY> tag of the page you want to protect:
<script language=JavaScript><!–//Disable right mouse click Script//By Maximus ( maximus@nsimail.com ) w/ mods by DynamicDrive//For full source code, visit http://www.dynamicdrive.comvar message=”Function Disabled!”;///////////////////////////////////function clickIE4(){if (event.button==2){alert(message);return false;}}function clickNS4(e){if (document.layers||document.getElementById&&!document.all){if (e.which==2||e.which==3){alert(message);return false;}}}if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}document.oncontextmenu=new Function(“alert(message);return false”)// –></script><script language=JavaScript><!–//Disable right mouse click Scriptvar message=”Function Disabled!”;///////////////////////////////////function clickIE4(){if (event.button==2){alert(message);return false;}}function clickNS4(e){if (document.layers||document.getElementById&&!document.all){if (e.which==2||e.which==3){alert(message);return false;}}}if (document.layers){document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS4;}else if (document.all&&!document.getElementById){document.onmousedown=clickIE4;}document.oncontextmenu=new Function(“alert(message);return false”)// –></script>
<script type=”text/javascript”>/************************************************ Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)* 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 routetarget.onselectstart=function(){return false}else if (typeof target.style.MozUserSelect!=”undefined”) //Firefox routetarget.style.MozUserSelect=”none”else //All other route (ie: Opera)target.onmousedown=function(){return false}target.style.cursor = “default”}//Sample usages//disableSelection(document.body) //Disable text selection on entire body//disableSelection(document.getElementById(“mydiv”)) //Disable text selection on element with id=”mydiv”</script>Once this code is in place in the <HEAD> of your web page(s) you will need to add the following snippet of code to the bottom of every page you want to protect:
<script type=”text/javascript”>disableSelection(document.body) //disable text selection on entire body of page</script>
