[thelist] Protecting your code from viewing

The Optimizer chrism at puffofsmoke.net
Mon Nov 12 08:13:04 CST 2001


> A while back I remember a thread being discussed about the possibility of
> hiding or protecting your code from being seen by viewing the source.
[..]
> Just curious as to how this is done for future reference.

There are a number of event handlers that allow this to be done.

Placed in the body tag:

ondragstart="event.returnValue=false"
onselectstart="event.returnValue=false"
oncontextmenu="event.returnValue=false"
onkeydown="event.returnValue=false"

will disable pretty much everything. This is not a solution for browsers
other than IE, and they will only work in certain versions of IE (AFAIK).
This still only protects your code from the most casual of thieves, as even
by blocking the user from viewing in another browser will not prohibit them
from simply lifting the code viewed in IE from the browser cache.

Hope this clarifies somewhat.

Regards

Chris Marsh





More information about the thelist mailing list