| PROTECTING YOUR CODE AND IMAGESScript showing your own message (see below) BODY TAG Code Protection | We have received a number of requests for information on how to protect your source code, and especially, your images from being taken from your Web site. While there is no way to stop visitors from grabbing files from their browser cache, most people are too lazy or slow to figure this out. So, if you follow the methods below, you will deter most surfers from taking your code or images from your site. | The following script will call a JavaScript Alert Prompt telling the user that right-clicking images has been disabled. Place this script any where on your page and give it a try ... | <script language="JavaScript"> <!-- var message="Sorry, we don't allow right clicks on this site!."; // Put your message for the alert box between the quotes. // Don't edit below! function click(e) { if (document.all) { if (event.button == 2) { alert(message); return false; } } if (document.layers) { if (e.which == 3) { alert(message); return false; } } } if (document.layers) { document.captureEvents(Event.MOUSEDOWN); } document.onmousedown=click; // --> </script>
Download this script try it out - right click on this page NOW | BODY TAG Code ProtectionAll of the below tricks employ a tiny snippet of scripting code inside your page's BODY Tag. Try some of these to get a feel for what they accomplish when embedded into the tag.
Disable Right Click (to View Source):
<body oncontextmenu="return false"> ( no message shown ) Disable Mouse Dragging (Highlighting):
<body ondragstart="return false">
Disable Keyboard Use (Select/Copy):
<body onselectstart="return false"> Combine them all:
<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">
| | Now, one thing you're thinking is ... "sure, they can't right-click my images, but they can still grab all of my code, right?" Yes, that's true, so here's a way to deter code-grabbers. Use this little trick (it's kind of sneaky). Before writing any code for a page, add a pile of carriage returns (spaces) above your code. When visitors try to view your source code, they'll just see a big blank page ... because your code is hiding way down the page. It's not rocket science, but it works! |
|
| |