1

I wonder how to hide the source code of a web page. This is an example of webpage with hidden source (right click -> view page source). Any ideas or suggestions?

UPDATE I fully agree, that fully hiding HTML source is impossible, otherwise the browser could't parse it. Using tools like FireBub etc. will show you the source. The interesting in the example above in that on "show source code" the displayed page does not match the output. Now I understand it is just another kind of technology used here - XSLT. Thanks for your replies!

filip_j
  • 993
  • 1
  • 14
  • 22
  • 2
    That technique prevents only the most novice users from looking at the source code...in other words, it does absolutely nothing. – Brad M Aug 14 '13 at 19:29
  • 1
    The source of your link is this: ` BG Login При проблем със зареждане на сайта, моля опитайте / If you can't access the site, please try: https://e-fibank.bg/EBank/Mobile ` – chtenb Aug 14 '13 at 19:30
  • You can disable right click through javascript, but there will always be some way to see the output code – JTC Aug 14 '13 at 19:32
  • 2
    It isn't hidden, it's just using XML and [XSLT][1]. All the page's code is at https://e-fibank.bg/EBank/xslt/login.xslt. [1]: http://en.wikipedia.org/wiki/XSLT – Trevor Dixon Aug 14 '13 at 19:33

3 Answers3

5

If your page is generated dynamically (by Javascript), then it using View Source will not show anything (or very little, anyway). I suspect that's how your example is doing it.

Bear in mind that any page generated this way will still be visible by using a code inspector such as Firebug. So as @Brad M says, this will only stop people who don't really know what they're doing.

If you build the entire page in Java or Flash (or something similar like Silverlight I guess) then it's a lot harder for someone to find out what the source code is (though Java is pretty easy to decompile)

1

There is no way to hide your code from a client that must execute the code. Your example just did some trick to prevent right-clicking and stuff. But eventually you can get your way around.

chtenb
  • 14,924
  • 14
  • 78
  • 116
0

For interpreted language such as javascript, the following adage is true. " Lock on the door is only for the one who don't care. If there comes thief, most of the time he is already prepared."

All you can do to prevent is obfuscating your code. That will prevent it for some time. But remember, if they are going to crack it, it is not unstoppable. The basic thing to remember is: your script is going to run on the client side and is "INTERPRETED" by browser. In these days, when there are few tools that can create source code from compiled file, the thought of hiding javascript code is even not thinkable. This How can I obfuscate (protect) JavaScript? can help you on how to do it.

Community
  • 1
  • 1
Jack_of_All_Trades
  • 10,942
  • 18
  • 58
  • 88