Take the 2-minute tour ×

Is it possible I create a webpage that doesn't allow the website source to be displayed?

share|improve this question

migrated from superuser.com Feb 11 '11 at 9:17


No. You're asking to break functionality in a web browser. The only difference between how your site looks in the browser and the source is how the browser renders it. –  user114600 Feb 11 '11 at 7:38
It's actually quite easy: Password-protect it (.htaccess) and give nobody the credentials. It's a problem similar to that of the movie and software industry. They need to give you their goods for viewing/regular use, but want to prevent further access. Like giving someone a key to a door and wanting them not entering the room behind. It just doesn't work. –  Daniel Beck Feb 11 '11 at 7:47
Don't upload it... –  BloodPhilia Feb 11 '11 at 8:45
@DanielBeck The Only Secure Computer Is One That's Unplugged, Locked In A Safe, And Buried 20 Feet Under The Ground In A Secret Location. –  likeitlikeit Apr 14 '13 at 16:18
@likeitlikeit The question states doesn't allow, not makes it impossible. Also, this was over two years ago. Really? –  Daniel Beck Apr 14 '13 at 16:33

6 Answers 6

up vote 1 down vote accepted

No, you cannot hide the plain text HTML output of your web server.

How the HTML is generated is separate form the actual HTML that gets sent from the server.

This is the way the internet and world wide web were designed. If you are using a server-side scripted web application to generate your HTML, then your business intelligence / process / code is hidden, provided that people do not have access to browse the actual script file on your server.

If you would like to customize one of the open source browsers, like Firefox or Chrome, you could disable the "view source" functionality. It might be a worthwhile option for certain intranet or internal business applications. XUL and Firefox is one of the possibilities our company looked at to control what the end user could access. The only real security you have to keep your source secure is on the server side, as network / protocol monitors could still pull the HTML as it moves over the network.

share|improve this answer

i have use block methode disable right click but still can view source on chrome using metode tipe to address bar view-source:example.com

disable right click

<script type='text/javascript'>
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
else //All other route (ie: Opera)
target.onmousedown=function(){return false}
target.style.cursor = "default"
<body oncontextmenu='return false;'>
<script type='text/javascript'>
share|improve this answer

Here is an example of a site with "view source code" disabled in any browser: http://www.transelectrica.ro/StareSistem/protocoale/starea_sistemului.php The question is: HOW THEY DID IT?

share|improve this answer
That's not really an answer, but still an interesting thing. Apparently, they use an image. However, of course, both Firebug and Chrome Inspector still show the HTML. However, the show source links are actually greyed out. –  likeitlikeit Apr 14 '13 at 16:01
This page, although it is served by a PHP file, actually only transmits a PNG image. Thus, there is no source code to display –  likeitlikeit Apr 14 '13 at 16:14

You might use plugin based content, like a java applet, Flash, etc., to somewhat "hide" the real content. Of course, as eventually it will be displayed on screen, there is nothing to prevent a determined user to reverse engineer your page.

share|improve this answer


share|improve this answer
Could you please drop a line concerning the reason for this? –  Mehper C. Palavuzlar Feb 11 '11 at 9:11
@Mehper C. Palavuzlar: A reason shouldn't be needed. Anything that can open a file through the HTTP protocol can obviously view the source of said file. Heck, notepad can open a URL and it certainly doesn't care what the contents of the html file are. –  Chris Lively Feb 11 '11 at 22:25

From encrypt-html.com:

Almost all browsers provide a convenient way to view the source code of the currently opened page. We regularly receive e-mails with the same question - how to disable view source command.

An html file can not enable or disable the built in browser functionality in most cases. It's not possible remove the view-source command from the browser menus or to make it non-working. But if the source is encrypted, what the user will see is just a lot of garbage characters - not your original code. So the view source command is practically disabled for each encrypted file.

share|improve this answer
You may also want to read this. –  Mehper C. Palavuzlar Feb 11 '11 at 7:41
Encrypting HTML do not protect against DOM viewers (for example Google Chrome natively shows parsed DOM tree, by right-clicking and selecting "Inspect element"). –  Olli Feb 11 '11 at 8:48
Encrypting the "source" does nothing other than prevent a casual person from viewing source as everything necessary for decrypting said file has to be available in a javascript function in the source itself. –  Chris Lively Feb 11 '11 at 22:27

Your Answer


