Hide Your HTML Source

Sometimes you might not want to allow guests to your website to view the HTML source code. You can disable the right click context menu by using the following bit of code in your page:

<body oncontextmenu='return false;'>

You can use this feature to prevent users from right clicking and saving an image from your site. This is support by IE and Firefox. I have seen sites use similar functionality to this to pop up an alert with a copyright message is a user tries to right click on an image.

Keep in mind that a user can always disable JavaScript altogether, view the source from the application menu, and/or even save the whole HTML file onto his/her desktop and view the source from Notepad.

Related posts:

  1. Disable Right Click Menu in HTML
  2. HTML FieldSet Tag
  3. Print HTML Using IE
  4. Remove Invalid Ruby Gem Source
  5. CDATA With XSLT
  6. JavaScript Debugging With The console Object


One Response to “Hide Your HTML Source”

Leave a Reply