Contents:
JavaScript Overview
Client-Side JavaScript Examples
The JavaScript Reference Pages
JavaScript is an evolving scripting language that can be used to extend the capabilities of HTML pages on the World Wide Web. At the end of this chapter is a concise summary of the various JavaScript objects, and the properties, methods, and event handlers defined for them. If you're already writing JavaScript code, this section should help refresh your memory about specific names and syntaxes. For newcomers, we also provide an overview of JavaScript and its capabilities. But if you want to learn JavaScript, you'll have to consult a book devoted to it, such as JavaScript: The Definitive Guide, by David Flanagan, published by O'Reilly & Associates.
JavaScript is being developed by Netscape Communications Corporation for use in their Netscape Web browser (client-side JavaScript) and their Web server products (server-side JavaScript). The core JavaScript language has become fairly stable in Netscape 3.0. However, the final JavaScript specification is still pending and plenty of features are still being tuned and added. (In Netscape 2.0, the version of JavaScript is much more limited.) Despite the beta status of JavaScript, tremendous numbers of people are already using it, and Netscape is offering it freely to the market in an attempt to create a standard.
But what is JavasScript and what does it actually do? It may be natural to assume that JavaScript is a simplified version of Java, the programming language from Sun Microsystems, but this is not the case. As a matter of fact, other than an incomplete syntactic resemblance and the ability of both languages to deliver "executable content" over networks, JavaScript and Java are entirely unrelated.
However, Java and JavaScript do provide complimentary capabilities, and thus work very well together. JavaScript can control browser behavior and content but cannot draw graphics or perform networking. Java has no control over the browser as a whole, but can do graphics, networking, and multithreading. In Netscape 3.0, JavaScript can communicate with the Java interpreter built into the browser and can work with and control any Java applets in a Web page.
JavaScript is a simple, interpreted programming language. Client-side JavaScript is JavaScript embedded into HTML Web pages. It allows "executable content" to be distributed over the Internet. (Currently the only JavaScript-enabled browsers are Netscape versions 2.0 and 3.0, and Microsoft Internet Explorer version 3.0.) An example of a client-side JavaScript application appears later in this chapter.
Server-side JavaScript provides an alternative to CGI scripts but goes a step beyond: the code is embedded directly within HTML pages and allows executable server-side scripts to be intermixed with Web content. Server-side JavaScript dynamically generates HTML that is displayed by the client. But its most powerful features come from the server-side objects it has access to. The File object, for example, allows a server-side script to read and write files on the server. Keep in mind, however, that (as of this printing) Netscape's server-side JavaScript product, LiveWire, is still in beta testing, and no other vendors have yet developed products incorporating this technology.
Here's an overview of some of the things you can do with JavaScript:
These are just a few of JavaScript's many capabilities. JavaScript can be used to greatly enhance your HTML code.
This HTML Help has been published using the chm2web software. |