Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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).

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?

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

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top