internet.com

Go to WebDeveloper Home


hm-v6-139x61.gif

Database Journal: The Knowledge Center for Database Professionals

find a web host with:
CGI Access
DB Support
NT Servers
UNIX Servers
Telnet Access

advanced search
jobs

Get FREE Development Info via your Email!

The Webdeveloper channel
FlashKit
GIF.com
HiermenusCentral
webdeveloper Jobs
Java Boutique
JavaScript.com
JavaScript Source
ScriptSearch
StreamingMedia World
WDJ
WDVL
WebDeveloper.com
WebReference.com
XMLFiles.com

internet.com
Internet News
Internet Investing
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
ECommerce/Marketing
ISP Resources
ASP Resources
Wireless Internet
Downloads
Internet Resources
Internet Lists
International
EarthWeb
Career Resources

Search internet.com
Advertise
Corporate Info
Newsletters
E-mail Offers

internet.commerce
Be a Commerce Partner










Library

Jiving with Javascript, Part II

By Kevin M. Savetz

"Contrary to popular misconceptions, JavaScript was not meant to be a scaled-down version of Java, nor was it intended to be a replacement for CGI [server-side] scripts. Instead, JavaScript functions as an outstanding way to enhance both," he said.

JavaScript can be used to manage user input as well as to show text, play sounds, display images, or communicate with a plug-in in response to "events" such as a mouse click or entry to a Web page.

JavaScript's syntax is loosely based on the Java language, but those who have used both languages say the similarity is very loose indeed. In fact, the closest resemblance the two languages have are their names. JavaScript was originally called "Mocha" while being developed at Netscape Communications. It was later dubbed LiveScript, and when Netscape partnered with Sun to develop Java, LiveScript was renamed JavaScript.

Java vs. JavaScript

JavaScript programs are interpreted and run entirely on the client side. This means fewer hits on the server than with Java (whose applets are compiled on the server before being interpreted by the client) or CGI (which requires that the server both do the work and take the hits).

There are other differences between these two languages. In Java, applets are distinct files from HTML pages; with JavaScript, the code is integrated into the HTML using special tags. This can cause problems with some Web browsers that do not properly handle--or ignore--JavaScript code. Like Java, JavaScript is a cross-platform language that can work with any compatible browser.

Figure 1 shows an example HTML file with an embedded JavaScript. Between the <BODY> tags, the Web browser displays a form with a space to enter a number. When the user enters a number in the field, the browser starts the script, located between the <SCRIPT> tags. The script itself makes sure the user really entered a number, and displays a dialog box if the user didn't keep the number within predefined limits.

All this takes only one hit on the server to download the HTML code and the embedded script. Doing this with a CGI script would require multiple hits on the server: once for the HTML file, and again to verify the input every time the user types into the form. JavaScript allows the client to perform more significant calculations without loading down the server.

[Move on the Part III]


Reprinted from Web Developer® magazine, Vol. 2 No. 2 Spring 1996 (c) 1996 internet.com Corporation. All rights reserved.


Web Developer® Site Feedback
Web Developer®
Copyright © 2000 internet.com Corporation. All rights reserved.

Web Developer® Home Over a dozen topics in detail Live Chat Downloads Book and Product Reviews Threaded Discussions How-To/Articles/Links Developer Daily News Subscribe Search Corporate Information Advertise Events Publications internet.com Home