|
Protecting your site's content
Protecting your HTML code
By Mike Slocombe for Internet Magazine, Feb 2004
1. No right click
Some authors use JavaScript to disable the right mouse click in a vain attempt to stop people looking at their source code.
Not only is it easy to get around this by a variety of methods (like simply saving the page) it usually only succeeds in really annoying visitors.
<SCRIPT>function click()
{if (event.button==2)
{alert('Ooops...\nRight click is disabled!');}
}document.onmousedown=click//
-->
</SCRIPT>
Related article: Don't disable right click!
2. Software protection
Several commercial products like HTML Protector
claim to prevent visitors from seeing your source code.
All they actually do is call up a JavaScript function called 'unescape' which 'encodes' the HTML code into a long string of characters.
Unfortunately, these can easily be converted back to HTML using a similar piece of JavaScript.
See how it's done here: Protect Your Code and Graphics - Or Not or download a free PHP obfuscating HTML encoder
3. Stripping your HTML
Stripping out all the spaces in your HTML code so that your code is in one big long line can make it much harder for people to read.
The good news is that it'll also make your pages faster to download.
The bad news is that editing it afterwards can be a right royal pain!
Download out this freeware program which removes any unnecessary space and new-line characters: HTML Optimizer
|