1. Giving the user more control over the browser.
Example: Here you can change the background color of this page as well as the text on the browser's status bar.
2. Detecting the user's browser and OS. The ability to detect the user's browser and OS allows your script to perform platform-dependent operations, if necessary.
Example. Here users of different browsers will get different greetings:
3. Performing simple computations on the client side.
4. Validating the user's input.
Example. In the calculator above, try typing some letters instead of numeric input. You'll get a warning: Invalid input characters!
5. Handling dates and time.
Example 2. This script says "Nice morning, isn't it?" or "Good afternoon!" or "Good evening!" or "Wow, you are not asleep yet!?" depending on the current time. It also tells you today's date.
6. Generating HTML pages on the fly.
Example. The Table of Contents on the left is dynamically expandable. To view all subsections in a section, you can click on the white arrow corresponding to that section. To hide subsections, click on the arrow .