1. Home
  2. Computing & Technology
  3. JavaScript

Design for Usability
What Not to Do

By Stephen Chapman, About.com

There are a number of things that a lot of newcomers to JavaScript want to do with it that either can't be done or which shouldn't be done even when they can be done since doing so reduces rather than enhances the usability of your web page.

The primary thing that everyone appears to want to use JavaScript for but which it can't do is to protect the content of your web page so as to stop your visitors stealing your images or viewing the source of your page. JavaScript can't do this because the web browser has already copied all of your page content to your visitor's computer before it displays the web page to start with.

Encrypting your entire page content using JavaScript will stop those people without JavaScript from being able to view your web page at all while for those with JavaScript enabled the browser has to decrypt the content in order to display it and your visitor can easily gain access to that decrypted version.

Other forms of "protection" such as blocking the context menu that is displayed when the right mouse button is pressed do not affect those with JavaScript disabled and interfere with your visitor's legitimate use of the functionality of their own browser. The knowledgeable visitors will simply disable that code while the less knowledgeable will simply leave your site and go elsewhere. Those looking to access the source that you are trying to protect will not even know that you have applied any JavaScript techniques to try to protect your content as they will access that content in a way that completely bypasses whatever you might have in place.

The real reason why the content of "protected" web pages doesn't get stolen very often is that the fact that the page owner doesn't know enough about how the web works to know how ineffective such protection is clearly demonstrates that there is unlikely to be anything in their page worth stealing. When adding JavaScript to your web page you need to ask yourself why you are adding the JavaScript. Is this script intended to be for your benefit or is it intended to benefit your visitors by making your page easier to use. If the script will interfere with your visitors legitimate use of their own browsers then it does not belong on your site.

Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript
  4. Javascript Tutorials
  5. What Not to Do>

©2009 About.com, a part of The New York Times Company.

All rights reserved.