How can I disable the user viewing the source code of my HTML page?

Joseph Shelby

There are tricks that can be used to disable the pop-up menu, and when combined with opening a new window (with the property settings to disable the menu-bar and toolbars) this can effectively keep the source of the new window's document from being viewed easily, by amateurs at least. Note that these both depend on Javascript, which can be disabled to allow the page to be seen "normally". Dhtml Diner has a discussion on disabling the pop-up menu.

However, anything on the "web" is free reign. An experienced engineer with their own tools such as web-spiders can easily follow the links and grab the pages, images and javascript code regardless of where its "hiding". If a browser can find it, then any tool that knows http can find it, you can't hide it.

So you have these solutions if you really want to keep certain things "private":

  1. Don't put it on the web.
  2. Hire a lawyer and be ready to fight on violations of copyright law.
  3. Use proprietary tools for content delivery like Shockwave, Flash, or Java Applets.
  4. Give it up. The web was meant for sharing, not keeping things a secret.