Developer

Get an overview of JavaScript

JavaScript offers a way to add intelligence and interactivity to Web pages. Here are several things you can do with JavaScript.

By Emily A. Vander Veer

JavaScript offers a way to add intelligence and interactivity to Web pages. With JavaScript, you can:

  • process data collected in HTML forms right on the user's computer, without involving a server (or a programmer with advanced Perl, C, or other programming language skills)
  • create and store data on the user's machine
  • add interactivity to graphics
  • change page elements on the fly based on user input; and
  • integrate HTML data more tightly with other Web technologies (for example, Java applets and ActiveX controls).

Before JavaScript

Before JavaScript, creating interactive Web pages was far more difficult—for the page designer and the hardware. Collecting and processing user data required something called a common gateway interface (CGI) script that ran on the Web server. To use a CGI script, you first design an HTML-based Web page containing forms to gather input from users. Then you create (or pay someone to create) a CGI script in C or Perl to process the gathered input on the Web server.

Unfortunately, each time a user views the page and submits the form, the data travels from the Web browser to the CGI script. The CGI script then processes the data and returns any results to the user in the form of a new HTML-based Web page. This happens every time a user makes changes to the Web form, thus soaking up the server's CPU power and wasting time sending information back and forth across the Internet connection.

Why Use JavaScript?

JavaScript solves many of these problems by collecting and processing the data inside the browser on the user's system, although you may still need to send the processed data to a CGI script afterward. JavaScript is also an interpreted language, meaning it doesn't end up as an executable file for a specific computer. Instead, the code runs only on a JavaScript interpreter in the user's browser. You can write JavaScript code once, and it will work on any system with a JavaScript-capable browser (Netscape Navigator 2.0 or later, or Microsoft Internet Explorer 3.0 or later) on any computer platform.

Emily A. Vander Veer is the author of numerous Internet-related magazine articles and books, including JavaScript for Dummies, JavaScript for Dummies Quick Reference, and JavaBeans for Dummies, all published by IDG Books.

Editor's Picks

Free Newsletters, In your Inbox