I saw How to hide html source & disable right click and text copy? . One of the answers say use ctrl+u to view the source. But, using shortcut.js I can override ctrl+u as well. How do I view source in that case.
-
off course we can stop the scripts, is there any other way – hrishikeshp19 Apr 09 '12 at 19:11
-
1`wget` is always pretty easy too.. – Mike Christensen Apr 09 '12 at 19:12
-
1You can use Ajax. Check my answer please. – Shiplu Mokaddim Apr 09 '12 at 19:25
-
for the downvoters: this isn't a bad question as it strikes at something fundamental. The problem is the approach to a solution that is broken. All that's needed is direction. – Scott M. Apr 09 '12 at 19:40
-
@shiplu.mokadd.im cool. a situation where wget or curl will fail. – hrishikeshp19 Apr 09 '12 at 19:44
-
no they will not fail completely. any clever person can find get it with tcpdump or wireshark like tools. But thats not easy and very few normal use will do it. – Shiplu Mokaddim Apr 09 '12 at 20:06
-
possible duplicate of [How to hide html source?](http://stackoverflow.com/questions/6597224/how-to-hide-html-source) – Brad Apr 10 '12 at 14:31
9 Answers
There is no way to prevent this. Someone could easily download the page using a non-browser tool like curl or wget, or log all HTTP traffic with Wireshark.

- 278,309
- 50
- 514
- 539
Depends on the browser, but you can go to View -> Page Source
in most to view the source. You cannot override that, however.
Furthermore, it's considered bad practice, and someone could also just as easily override the functionality through a tool like Firebug.

- 33,276
- 14
- 79
- 112
You can't stop people. It will be passed over the network, and sniffable through Fiddler, or someone can use a text based browser, or disable Javascript entirely, or look through their cache folder for the files they downloaded from your site.
You cannot stop people from seeing your source.

- 31,971
- 6
- 56
- 67
Well it's not possible to prevent users from seeing your script. But what you can do is to make it mire harder that user quits trying after few common methods.
I recommend you to load an initial page. Then load the whole page by using ajax. You can show a friendly loading gif too. This technique has following adanages,
- browsers don't show generated HTML. Developers knw how to see this. But Normal user will not find it easily
- if any user just press Ctrl+u it'll show the initial page.
- wget, curl tool will not work at the first time.
- additionally you can obfuscate the main page (which you are going to load by Ajax).

- 56,364
- 17
- 141
- 187
It's nearly impossible to stop people fetching the HTML from your website. I don't see any reason you'd want to hide it in the first place anyway. Hiding something?

- 154
- 9
Want to view the source no matter what javascript is being used to hide it? cURL
the page.

- 41,754
- 51
- 164
- 239
Even if you disable right-click, you can still do a snapshot by pressing the prt scrn key on your keyboard then pasting it into an image editor.
You can't disable it. There are ways to encrypt it, but way more trouble than it's worth.

- 87
- 5
It's impossible to hide the source, HTML and Javascript are interpreted languages, that mean the browser will "compile" the code on the clients machine.

- 9,552
- 4
- 50
- 78

- 1,149
- 9
- 30