★ wanayoo — archive 1999 http://webdeveloper.com/javascript/javascript_jiving_2.htmlNouvelle recherche | Portail wanayoo
internet.com

Go to WebDeveloper Home

Seek and you shall

or search all of internet.com
Looking for a Site Map?
Vote for WD!
Please keep
voting for us
as a Top 100
Web site!

The Web Developer Network
WebDeveloper.com
Streaming Media World
WebReference.com
Web Developer's Virtual Library
BrowserWatch
Java Boutique
Web Developer's Journal
JavaScript Source
ScriptSearch
Web Developer Forums
Web Developer News

internet.com
Internet News
Internet Stocks/VC
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
E-Commerce/Marketing
ISP Resources
Downloads
Internet Resources
Internet Lists
International

Search internet.com
Advertising Info
Corporate Info
Internet Trade Shows

internet.commerce
Be an Affiliate
Be a Partner
Software Store
Computer Help
Register a Domain
Be Domain Registrar
e-solutions
Internet Jobs
A/V Network
Map Your Website
Rent E-mail Lists
Bookstore
Press Release dist.
Sell Ad Space
Internet Research
Venture Capital
Web Publishing
Build Your Intranet
Expert Tech Advice
Get e-Biz Intell.
Content for Websites

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 © 1999 internet.com Corporation. All rights reserved.

http://www.internet.com
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