How to protect my code?

How do we protect our html page from view source code?

  • how we protect our html page that a page visitor cant view sourced of it?

  • Answer:

    You can't. See my long explanation as to what people have tried and why it didn't work: http://dorward.me.uk/www/hide/

suddu at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

There's no good way to do it. No matter what you try, in the end, the user's browser is going to decide whether or not it lets the user view the source, and there is no way for the server to control that (nor should there be). If there is sensitive information 'hidden' in the HTML, whether it's HTML, CSS or JavaScript, it shouldn't be there. It may just as well be published in a newspaper. If you're trying to protect the code, have it run on the server instead of the client. If you're trying to protect the formatting information (the HTML itself), you're out of luck. You can try to obfuscate it (make it harder to read), but that's generally going to make your site harder to maintain. It can't be encrypted in a traditional sense without making the browser unable to understand it. If you really want to spend the time and energy (which I'm not recommending), you could make it really hard to read by encrypting the page contents and using JavaScript code to decrypt and render it, but even if you do it that way, it'd take someone like me under ten seconds in Firefox to get it, because you'd have to give the browser the keys to the encryption too. I guarantee that whatever you're trying to hide is not worth the effort.

MD

That's not possible except you are concerned with certain web scripting technologies such as asp.net, php, jsp,coldfusion ...etc. When they run, they get rendered into standard HTML so no one will see the code, but for standard HTML code, it's a must to be there and you can't hide it; however, there are issues such as displaying your css, css could be better off written in a file and just called from your html script; hence, users will not be able to see the css you wrote. I still assume you might be concerned with server-side scripts which will not be shown. For instance: <cftable>...... in ColdFusion will be rendered to the clients as standard HTML <table> tag; <?php .. blabla will not be shown to the client, though it exists in your source of the file; <asp:menu .... might be rendered to some nested <table> tags to the end client and so on.

Coosa

you can use a freeware html encryption program. that will stop 99% of your visitors from "getting the source" you could use frontpage, because with all the junk it makes in the source no one would want to really look at it. ;)

beni_gabor

You can't. View Source is a function in virtually all browsers which display the source code of the website being viewed. This is a browser function, so anything you put on a website will not stop it. Why would you want ot hide the source anyway? What's the point? Every single website on the internet, without exception, has it's source code viewable.

Mighty Oats

Are you saying program source code? Because if I remember correctly, whatever program source code in your HTML page will NOT be shown to the viewer. The only thing the viewer see in their web page is the source code needed to view the page. No calculation/formula/algorithm/complex codings will be shown.

Eff

There are javascript codes that prevent the user from right clicking on your page.. However, I'm not sure there is a code to prevent going to View and clicking on Source. :P

Jjjjjjj

You can try googling for html scrambler etc.. This one encapsulates your entire source into a line of javascript that sort of obfuscates the code. http://www.hypergurl.com/generators/htmlscrambler.html There are several programs on this page also: http://protect-html-source.qarchive.org/ Regards, bleh -_-

kaonic_decay

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.