About This Product
FontsMadeEasy.com
 
Search This Database:
| Over 5000 Free Fonts | Tutorials | Javascript Forum | Other Javascript Resources | Cheat Sheet
Tutorial archive
General Questions
Javascript 1.2
Navigation
Numbers
Strings
Object Model
Reference Manual
Dialog
Windows
Frames
Forms
Images
Mouse Events
Colors
File Access
Control Status Bar
Dates and Time
Cookies
Client Information
Bookmarklets







[Contents] [Previous] [Next] [Last]


Introduction

This document describes the changes and new features for JavaScript in Navigator 4.0.

Feature Summary

Event Model

The event model, as described in Chapter 1, "Event Model," has changed to include a new event object, new events, and event capturing.

  • "The event Object" on page 21 contains properties that describe a JavaScript event, such as the event type and the cursor location at the time of the event. The object is passed as an argument to an event handler when an event occurs.
  • "Event Capturing" on page 24 enables a window or document to capture an event before the target object (link, button, etc.) gets the event. The window and document objects have these new methods to support event capturing:
  • Objects that receive events have these new methods for event capturing:

    • routeEvent--routes the event from its capturer through its normal event hierarchy.
    • handleEvent--fires the event handler for the specified event.
  • Events have been added or revised.
    • Click*--occurs when a user clicks a link or form element.
    • DblClick--occurs when a user double-clicks over a link or form element.
    • DragDrop--occurs when a user drops an object onto a Navigator window.
    • KeyDown--occurs when a user depresses a key.
    • KeyPress--occurs when a user presses or holds down a key.
    • KeyUp--occurs when a user releases a key.
    • MouseDown--occurs when a user depresses a mouse button.
    • MouseMove--occurs when a user moves the cursor.
    • MouseOut*--occurs when a user moves the cursor out of an object.
    • MouseOver*--occurs when a user moves the cursor over an object.
    • MouseUp--occurs when a user releases a mouse button.
    • Move--occurs when a user or script moves a window.
    • Resize--occurs when a user or script resizes a window.

Functions

Layers

Layers, new in Navigator 4.0, let you define overlapping layers of transparent or solid content in a web page. Each layer in HTML has a corresponding layer object that allows you to use JavaScript to manipulate the layer.

Methods

Array Methods

  • concat--joins two arrays and returns a new array.
    • pop removes the last element from an array and returns that element.
    • push adds one or more elements to the end of an array and returns that last element added.
    • shift removes the first element from an array and returns that element
    • unshift adds one or more elements to the front of an array and returns the new length of the array.
  • slice--extracts a section from an array and returns a new array
  • splice--adds and/or removes elements from an array and returns the removed elements.
  • sort*--now works on all platforms. It no longer converts undefined elements to null; instead, it sorts them to the high end of the array.

Document Method

  • getSelection--returns a string containing the text of the current selection.

Navigator Method

  • preference--allows a script to get and set certain Navigator preferences, such as enabling or disabling Java.

String Methods

Window Methods

Shared Methods

  • eval--no longer a method of individual objects; only available as a global function.
  • watch--new method of all objects. Watches for a property to be assigned a value and runs a function when that occurs.
  • unwatch--new method of all objects. Removes a watchpoint set with the watch method.
  • captureEvents--window and document method. Sets the window or document to capture the specified events.
  • handleEvent--method of all objects with event handlers. Invokes the handler for the specified event.
  • releaseEvents--window and document. Sets the window or document to release the specified events.
  • routeEvent--window and document method. Passes a captured event along the normal event hierarchy.
  • toString*--converts the object or array to a literal. For this behavior, LANGUAGE="JavaScript1.2" must be specified in the <SCRIPT> tag.

Objects

Operators

Properties

Anchor and Link Property

Function Property

  • arity--indicates the number of arguments expected by a function.

Navigator Properties

  • language--indicates what translation of the Navigator is being used. This property is particularly useful for JAR management.
  • platform--indicates the machine type for which the Navigator was compiled. This property is particularly useful for JAR management.

Window Properties

Regular Expressions

Regular Expressions are patterns used to match character combinations in strings. In JavaScript, you create a regular expression as an object which has methods used to execute a match against a string. You can also pass the regular expression as arguments to the String methods match, replace, search, and split. The RegExp construction object has properties most of which are set when a match is successful, such as lastMatch which specifies the last successful match. Finally, the Array object has new properties that provide information about a successful match such as input which specifies the original input string against which the match was executed.

This section includes:

Signed Scripts

For additional power and functionality, scripts can now gain access to normally restricted information. This is achieved through signed scripts that request expanded privileges. This new functionality provides greater security than data tainting. Data tainting has been removed from JavaScript 1.2.

Statements

  • The break* and continue* statements can now be used with the new labeled statement.
  • do while--repeats a loop until the test condition evaluates to false.
  • export--allows a signed script to provide functions to other signed or unsigned scripts.
  • import--allows a script to import functions from a signed script which has exported the information.
  • labeled--allows the program to break outside nested loops or to continue a loop outside the current loop.
  • switch--allows the program to test several conditions easily.

Style Sheets

Using style sheets, you gain finer control over the presentation of your web pages. Navigator 4.0 supports two syntaxes for designing style sheets: Cascading Style Sheets (CSS) and JavaScript style sheets. CSS is the static approach to specifying style and JavaScript is the programmatic approach.

Miscellaneous

Compatibility With Earlier Versions of Navigator

As JavaScript evolves along with Navigator, its capabilities expand greatly. This means that JavaScript written for Navigator 4.0 may work in Navigator 4.0 only. To ensure that users of earlier versions of Navigator avoid problems when viewing pages that use JavaScript 1.2, use the LANGUAGE attribute in the <SCRIPT> tag to indicate which version of Javascript you're using. If you use LANGUAGE="JavaScript1.2", you need to be aware of the equality rules described below.

Statements within a <SCRIPT> tag are ignored if the browser does not have the level of JavaScript support specified in the LANGUAGE attribute; for example:

By using the LANGUAGE attribute, you can write general JavaScript that Navigator version 2.0 and higher recognize, and include additional or refined behavior for newer versions of Navigator.


[Contents] [Previous] [Next] [Last]