JavaScript lets you create applications that run over the Internet. Using JavaScript, you can create dynamic HTML pages that process user input and maintain persistent data using special objects, files, and relational databases. You can build applications ranging from internal corporate information management and intranet publishing to mass-market electronic transactions and commerce. Through JavaScript's LiveConnect functionality, your applications can access Java and CORBA distributed object applications.
Server-side and client-side JavaScript share the same core language. This core language corresponds to ECMA-262, the scripting language standardized by the European standards body, with some additions. The core language contains a set of core objects, such as the Array
and Date
objects. It also defines other language features such as its expressions, statements, and operators. Although server-side and client-side JavaScript use the same core functionality, in some cases they use them differently. You can download a PDF version of the ECMA-262 specification.
The components of JavaScript are illustrated in Figure 1.1.
Figure 1.1 The JavaScript language.
Figure 1.2 Client-side JavaScript.
In contrast to pure client-side JavaScript scripts, JavaScript applications that use server-side JavaScript are compiled into bytecode executable files. These application executables are run in concert with a web server that contains the JavaScript runtime engine. For this reason, creating JavaScript applications is a two-stage process.
In the first stage, shown in Figure 1.3, you (the developer) create HTML pages (which can contain both client-side and server-side JavaScript statements) and JavaScript files. You then compile all of those files into a single executable.
Figure 1.3 Server-side JavaScript during development.
In the second stage, shown in Figure 1.4, a page in the application is requested by a client browser. The runtime engine uses the application executable to look up the source page and dynamically generate the HTML page to return. It runs any server-side JavaScript statements found on the page. The result of those statements might add new HTML or client-side JavaScript statements to the HTML page. It then sends the resulting page over the network to the Navigator client, which displays the results.
Figure 1.4 Server-side JavaScript during runtime.
JavaScript has the following core objects:
Array
, Boolean
, Date
, Function
, Math
, Number
, Object
, String
The additional client-side objects are as follows:
Anchor
, Applet
, Area
, Button
, Checkbox
, document
, event
, FileUpload
, Form
, Frame
, Hidden
, History
, Image
, Layer
, Link
, Location
, MimeType
, navigator
, Option
, Password
, Plugin
, Radio
, Reset
, screen
, Select
, Submit
, Text
, Textarea
, Window
These objects represent information relevant to working with JavaScript in a web browser. Many of these objects are related to each other by occurring as property values. For example, to access the images in a document, you use the document.images
array, each of whose elements is a Image
object. Figure 1.5 shows the client-side object containment hierarchy.
Figure 1.5 Containment relationships among client-side objects
blob
, client
, Connection
, Cursor
, database
, DbPool
, File
, Lock
, project
, request
, Resultset
, SendMail
, server
, Stproc
As shown in Figure 1.6, some of the additional server-side objects also have a containment hierarchy.
Figure 1.6 Containment relationships among LiveWire objects
JavaScript for Navigator 3.0 has a feature called data tainting that retains the security restriction but provides a means of secure access to specific components on a page.
For information on data tainting and on signed scripts, see Chapter 7, "JavaScript Security," in the JavaScript Guide.
Last Updated: 10/31/97 12:29:51