Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

The JavaScript FAQ
Prev Home Next

JavaScript Features

Question: What can JavaScript programs do?

Answer: The following list presents only some groups of typical tasks in which JavaScript proves very useful:

Below you'll find simple examples illustrating each of these tasks.

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.

And here is a Back button implemented with JavaScript. Click it, and you'll return to the page from which you arrived:

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.
Example. This is a JavaScript calculator: type an arithmetic expression, and JavaScript will compute its value.

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!

Note that JavaScript helps the browser perform input validation without wasting the user's time by the Web server access. If the user makes a mistake in the input, the user will get an error message immediately! On the other hand, if the input information is validated only on the server, then the user would have to wait for the server response.

5. Handling dates and time.
Example 1. This is a JavaScript clock.

Local 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 .

Every time you click on the arrows, the browser generates and displays a new HTML page in the left frame. Thanks to JavaScript, this operation is performed on the client machine, and therefore you don't have to wait while the information goes back and forth between your browser and the Web server.

JavaScripter.net. Copyright © 1999-2006, Alexei Kourbatov

The JavaScript FAQ
Prev Home Next


 
 
  Mirrored with kind permission of Alexei Kourbatov Design by Interspire