javascript - Common applications

I consider javascript the language of last resort. The browser compatibility and security issues associated with it can make it the most complex part of a page. For this reason, I strive to deliver pages to the browser ready for display. This isn’t always possible.

javascript is a vital part of web development, and I use it alot, but carefully. The following list describes some of the most common uses of javascript:

  • Alert boxes (usually just debugging)
  • Confirm boxes - great for ‘Are you sure … ‘ processing
  • Detection of form inputs changed to ensure user doesn’t lose changes
  • Changing state of buttons and inputs to disabled/readonly and back again
  • Changing status displays, like colors or text on the page
  • Opening new windows (window.open), often used for help and … Easter Eggs :)
  • Timers (see post about Ladybug)
  • Google (and other) Map APIs - these are cool http://code.google.com/apis/maps/documentation/
  • Hiding content / menuing, using style.display="block/inline/none”
  • Client-side validation and assisting the user in correcting errors, must revalidate on on server-side
  • Page level validation - Ensuring that inputs are not only valid, but valid with respect to each other - for example if the status is ‘extended absence’, a return date must be specified. As mentioned about, server-side validation must also be performed.
  • RIAs (Rich Internet Applications) - Sophisticated interfaces. These are usually based off javascript libraries & kits like dojo. Fundamental javascript skills are vital to work with the toolkits.
  • Control of players - like Windows Media player and Flash
  • Browser-specific page adjustments that can’t be done on the server-side
  • Used to add things like Google analytics, support external data collection systems http://www.google.com/analytics/, also Google ads
  • Choosing different .CSS files - often used to assist visually impaired site visitors with text size or color choices
  • AJAX
  • Input interaction - For example, if one input is chosen, another may be presented or set to a specific value