[Next] [Index]

JavaScript Guide

This book describes the core JavaScript language and extensions to that language for use with a browser. JavaScript is Netscape's cross-platform, object-based scripting language for client and server applications.

This book has been updated to include JavaScript 1.2 features, with the exception of JavaScript properties and objects that support layers and style sheets. For information on these subjects, see Dynamic HTML in Netscape Communicator.

Preliminary, last modified: 10/31/97.



What's New in Navigator 4.0
What You Should Already Know
How to Use JavaScript Documentation
Document Conventions

Part 1 Using JavaScript in Navigator

Chapter 1  Getting Started

This chapter introduces JavaScript, discusses some of the fundamental concepts of JavaScript in Navigator and provides basic examples. It shows JavaScript code in action, so you can begin writing your own scripts immediately, using the example code as a starting point.
What is JavaScript?
JavaScript in Navigator
JavaScript on the Server
JavaScript, the Core Language
JavaScript and Java
Embedding JavaScript in HTML
Using the SCRIPT Tag
Specifying a File of JavaScript Code
Using JavaScript Expressions as HTML Attribute Values
Using Quotation Marks
Specifying Alternate Content With the NOSCRIPT Tag
Defining and Calling Functions
Using the Write Method
Printing Output
Displaying Output
Validating Form Input
Example Validation Functions
Using the Validation Functions
Debugging JavaScript

Chapter 2  Handling Events

JavaScript applications in the Navigator are largely event-driven. Events are actions that occur usually as a result of something the user does. For example, clicking a button is an event, as is changing a text field or moving the mouse over a link. For your script to react to an event, you define event handlers, such as onChange and onClick.
Defining an Event Handler
Example: Using an Event Handler
Calling Event Handlers Explicitly
The Event Object
Event Capturing

Chapter 3  Using Navigator Objects

This chapter describes JavaScript objects in Navigator and how to use them. These client-side JavaScript objects are sometimes referred to as Navigator objects, to distinguish them from server-side objects or user-defined objects.
Navigator Object Hierarchy
Document Properties: an Example
JavaScript Reflection and HTML Layout
Key Navigator Objects
window and Frame Objects
document Object
Form Object
location Object
history Object
navigator Object
Navigator's Object Arrays

Chapter 4  Using Windows and Frames

JavaScript lets you create and manipulate windows and frames for presenting HTML content. The window object is the top-level object in the JavaScript client hierarchy; Frame objects are similar to window objects, but correspond to "sub-windows" created with the FRAME tag in a FRAMESET document.
Opening and Closing Windows
Opening a Window
Closing a Window
Using Frames
Creating a Frame
Updating a Frame
Referring To and Navigating Among Frames
Creating and Updating Frames: an Example
Referring to Windows and Frames
Referring to a Window's Properties, Methods, and Event Handlers
Referring to a Window in a Form Submit or Hypertext Link
Navigating among Windows and Frames

Chapter 5  LiveConnect

LiveConnect enables communication between JavaScript and Java applets in a page and between JavaScript and plug-ins loaded on a page. This chapter explains how to use LiveConnect in Netscape Navigator. It assumes you are familiar with Java programming.
Enabling LiveConnect
The Java Console
About the Netscape Packages
Using the Netscape Packages
JavaScript to Java Communication
Accessing Java Directly
Controlling Java Applets
Controlling Java Plug-ins
Data Type Conversion
Java to JavaScript Communication
Getting a Handle for the JavaScript Window
Accessing JavaScript Objects and Properties
Calling JavaScript Methods
Data Type Conversion

Chapter 6  Advanced Topics

This chapter describes some special concepts and applications that extend the power and flexibility of Navigator JavaScript.
Using JavaScript URLs
Using Client-Side Image Maps
Using Server-Side Image Maps
Using the Status Bar
Creating Hints with onMouseOver and onMouseOut
Using Cookies
Using Cookies with JavaScript
Using Cookies: an Example
Determining Installed Plug-ins
mimeTypes Array
plugins Array

Chapter 7  JavaScript Security

This chapter describes the security models of the JavaScript language for Navigator 2.0 and later releases. This model was extended significantly between the Navigator 3.0 and Navigator 4.0 releases.
Same Origin Policy
New Access Errors
Origin Checks and Layers
Origin Checks and Java Applets
Using Data Tainting in Navigator 3.0
How Tainting Works
Enabling Tainting
Tainting and Untainting Individual Data Elements
Tainting that Results from Conditional Statements
Using Signed Scripts in Navigator 4.0
Introduction to Signed Scripts
Identifying Signed Scripts
Using Expanded Privileges
Writing the Script
Signing Scripts
Troubleshooting Signed Scripts

Part 2 The Core JavaScript Language

Chapter 8  Values, Variables, and Literals

This chapter discusses values that JavaScript recognizes and describes the fundamental building blocks of JavaScript expressions: variables and literals.
Data Type Conversion
Variable Scope
Floating-Point Literals
Boolean Literals
String Literals
Array Literals
Object Literals
Regular Expression Literals

Chapter 9  Expressions and Operators

This chapter describes JavaScript expressions and operators, including assignment, comparison, arithmetic, bitwise, logical, string, and special operators. It also describes regular expressions.
Assignment Operators
Comparison Operators
Arithmetic Operators
Bitwise Operators
Logical Operators
String Operators
Special Operators
Operator Precedence
Regular Expressions
Creating a Regular Expression
Writing a Regular Expression Pattern
Working With Regular Expressions

Chapter 10  Object Model

This chapter describes how to use objects, properties, functions, and methods, and how to create your own objects.
Objects and Properties
Defining Functions
Using Functions
Using the arguments Array
Creating New Objects
Indexing Object Properties
Defining Properties for an Object Type
Defining Methods
Using this for Object References
Object Deletion

Chapter 11  Predefined Core Objects and Functions

Several objects are predefined in core JavaScript and can be used in either client-side or server-side scripts. These objects are in addition to objects defined for server-side JavaScript and Navigator objects introduced in Chapter 3, "Using Navigator Objects." A handful of predefined functions can also be used in both client and server scripts.
Array Object
Boolean Object
Date Object
Function Object
Math Object
Number Object
RegExp Object
String Object
eval Function
isNaN Function
parseInt and parseFloat Functions
Number and String Functions
escape and unescape Functions
taint and untaint Functions

Chapter 12  Overview of JavaScript Statements

JavaScript supports a compact set of statements that you can use to incorporate a great deal of interactivity in Web pages. This chapter provides an overview of these statements.
Conditional Statement
if...else Statement
switch Statement
Loop Statements
for Statement
do...while Statement
while Statement
labeled Statement
break Statement
continue Statement
Object Manipulation Statements and Operators
new Operator
this Keyword
for...in Statement
with Statement

Part 3 Appendixes

Appendix A  Reserved Words

This appendix lists the reserved words in JavaScript.

Appendix B  Color Values

The string literals in this appendix can be used to specify colors in the JavaScript alinkColor, bgColor, fgColor, linkColor, and vLinkColor properties and the fontcolor method.

Appendix C  Netscape Cookies

A cookie is a small piece of information stored on the client machine in the cookies.txt file. This appendix discusses the implementation of cookies in the Navigator client; it is not a formal specification or standard.

Appendix D  LiveAudio and LiveConnect

LiveAudio is LiveConnect aware. This appendix describes how you use JavaScript to control embedded LiveAudio elements.
JavaScript Methods for Controlling LiveAudio
Using the LiveAudio LiveConnect Methods

Appendix E  JavaScript Mail Filters in Navigator 4.0

This appendix tells you how you can use JavaScript to filter your incoming mail and news when you use Netscape Messenger.
Creating the filter and adding to your rules file
News filters
Message Object Reference
Mail Messages
News Messages
Debugging your filters
A more complex example


[Next] [Index]

Last Updated: 10/31/97 10:32:11

Copyright 1997 Netscape Communications Corporation

Casa de Bender