Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

hide code from visitor

Is it possible to hide the entire code (without any encryption) when visitor trying view my code using either of the following options:
Right click > view source OR View menu > source
Language used: java / vb script and asp / php
[243 byte] By [talwar75] at [2007-11-11 7:22:25]
# 1 Re: hide code from visitor
serverside code should already be hidden by your webserver. unless you specifically tell it to, apache should never show the source of your php.. only it's output

for html/javascript no it is not.. you can do several things to make the code harder to read however. including intercepting the right click event from the mouse therefor skipping the right-click menu.. but their browser has to have the html to render it, so they can get to it even if you were to disable the menus for some reason.. it will be in their cache

you could encrypt or rather obfuscate your javascript either on your own of through one of many products easily found through google. you could also do the same for your html... BUT your js and html will have to be functional so you really aren't hiding much to the non-n00b.
ednark at 2007-11-11 23:35:04 >
# 2 Re: hide code from visitor
I've seen the right click block scripts cause more problems than they are worth and can be a real inconvenience for visitors. I tend to right click to open in new windows a lot so that I don't lose the page I was on. Besides, those that want it usually know how to get without right clicking - the block right click is easily bypassed :D Unless it's a security issue with critical data, I wouldn't waste my time hiding it. One of the funniest things I see a lot of is people hiding the code and blocking right click when their sites are made with free scripts that anybody can get - that's just plain silly.
Ralyn at 2007-11-11 23:35:59 >