Introduction
The purpose of this page is to demonstrate different techniques that can be applied to improve usability via progressive enhancement using Javascript and the Document Object Model (DOM).
These techniques have been mostly adapted from examples provided in the excellent Chapter 11 Accessible Javascript written by Christian Heilmann in the book Web Accessibilty: Web Standards and Regulatory Compliance by Thatcher, Burkes, Heilmann et al. Javascript should always be implemented in an unobtrusive, accessible manner. If a user has Javascript disabled, they should still be able to use the page. The techniques will give examples of good and bad practices.
Before attempting to manipulate the DOM it is always good practice to check for browser support by both
- checking for the documents ID using getElementByID
- try to create a node using createTextNode as some older browsers support the DOM but do not implement it
If either test fails return and exit from the script so no more javascript is implemented. Provide the user with an alternative means of achieving the goal.