I expect that there are probably ways for a determined end user to see your code, but I would prefer to hide it.
Ideally, I would like to be able to hide it from OTHERS, but not me, in case I need to debug a live system.
Any suggestions?
I expect that there are probably ways for a determined end user to see your code, but I would prefer to hide it.
Ideally, I would like to be able to hide it from OTHERS, but not me, in case I need to debug a live system.
Any suggestions?
No. If the browser can "see" the source code, the user can see it too. There is no way to hide it.
No, the browser needs the HTML source to render the page. It's just one more step for the user to be able to view it. Period.
However, you can obfuscate it. Please think long and hard about why you need to do this, though. You'll probably find that this is not the correct solution.
It is not possible to hide HTML source from a end user since this source is response for the HTTP GET request from browser. But, you can encode/obfuscate the HTML code using Javascript; or you can disable right-click in a browser window using Javascript. But, these are not fool proof methods.
you cant able to hide it from browser .
Edited : removed the script i have given
As others have correctly said, you cannot hide either HTML, CSS, or JavaScript from the end user. You can just try to obfuscate it, but anyone who knows what he is doing will be able to reverse that easily.
A solution not mentioned here yet is to use Flash or Java applets instead of HTML. Naturally this has many drawbacks which I'm sure you are aware of yourself. And I'm not sure about the debugging possibilities. But that at least is quite difficult to decompile and it will allow you to do some things that you can't do with plain HTML/Javascript. Decide for yourself if this works for you or not.
I think you should consider what parts of it you actually wish to hide and why. If you don't want the user to be able to find out what your page is really doing, server-side code is probably the only option. Anything client-side like HTML or Javascript can and will be nosed into, obfuscated or not. And nobody likes it when you tinker with context menus.
If you're looking to hide it in a completely stupid fashion from completely stupid people, this would always work:
<!-- <PGA_LOAD_MODULE> --!>
#include('page_assets232.pga', 'mode=webViewer', true, false, true, true);
#asset_load(232, true, false, true, true);
#asset_init(232, true, false, true, true);
#asset_paint(232, true, false, true, true);
#asset_display(232, true, false, true, true);
#final_render('mode=webViewer', 232);
<-- </PGA_LOAD_MODULE> -->
[a ton of line breaks]
<!DOCTYPE html>
<html>
<head>
[etc.]
I'm sure plenty of cheap-o amateurs would very easily assume that your fancy commands up at the top actually mean something and ignore the scrollbar. I'm sure that a similar amount won't be fooled whatsoever. But given that there isn't actually a "real" solution, tricking the idiots who would be out to steal your page design may actually be a decent answer.
This approach might slow down casual users from viewing source: use JQuery's load
method (or corresponding call in the JavaScript library of your choice) to inject HTML into the DOM after the page has been loaded. When you view source, you won't see any of the loaded content in Firefox or IE. In order for you to view the source, you'll need to use a tool like Firebug which can display the current DOM tree. Of course if you can do that, other users can too... Also, there's nothing to prevent the user from viewing the URI of the load
call and just requesting the page you're loading directly.
Here's another solution that just came into my mind. If you set every possible no-cache no-store etc. HTML header you can find, some browsers will not allow you to view the source. This is because they don't save it to the disk, and somehow this disables their ability to show the source as well.
This is proven to work on Opera an IE. Not sure about FF/Chrome/Safari - test those yourself.
Note however that this is also trivial to bypass with any kind of HTTP debugging proxy (like Fiddler). Even the trivial javascript:alert(document.body.innerHTML)
in the address bar will show almost everything. This only protects against hacker-wannabe script kiddies.