JAVA SCRIPT

Информатика и компютърни науки Лекция

JAVA SCRIPT

2
JavaScript Reference

This book is a reference manual for the JavaScript language, including objects in the core language
and both client-side and server-side extensions. 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.
Contents
What's in this Reference

This reference is organized around the functionality of the JavaScript language.
Sometimes you already know the name of an object or method, but don't know
precisely where to look for it. This chapter contains tables of links to aid in this
situation.

Chapter 1 Introduction

This chapter briefly introduces JavaScript, Netscape's cross-platform, object-based
scripting language for client and server applications.

Client-Side JavaScript
Server-Side JavaScript
JavaScript Objects
JavaScript Security

Chapter 2 Operators

JavaScript has assignment, comparison, arithmetic, bitwise, logical, string, and special
operators. This chapter describes the operators and contains information about
operator precedence.

Assignment Operators
Comparison Operators
Arithmetic Operators
% (Modulus)
++ (Increment)
-- (Decrement)
- (Unary Negation)

Bitwise Operators
Bitwise Logical Operators
Bitwise Shift Operators

Logical Operators
Short-Circuit Evaluation

3
String Operators
Special Operators
?: (Conditional operator)
, (Comma operator)
delete
new
this
typeof
void

Chapter 3 Statements

This chapter describes all JavaScript statements. JavaScript statements consist of
keywords used with the appropriate syntax. A single statement may span multiple
lines. Multiple statements may occur on a single line if each statement is separated by
a semicolon.

break
comment
continue
delete
do...while
export
for
for...in
function
if...else
import
labeled
return
switch
var
while
with

Chapter 4 Core

This chapter includes the JavaScript core objects Array, Boolean, Date, Function,
Math, Number, Object, and String. These objects are used in both client-side and
server-side JavaScript.

Array
Properties
Methods

Boolean
Properties
Methods

Date

4
Properties
Methods

Function
Properties
Methods

Math
Properties
Methods

Number
Properties
Methods

Object
Properties
Methods

String
Properties
Methods

RegExp
Properties
Methods

Chapter 5 Document

This chapter deals with the document and its associated objects, document, Layer,
Link, Anchor, Area, Image, and Applet.

document
Properties
Methods

Link
Properties
Methods

Area
Anchor
Image
Properties
Methods

Applet
Layer
Properties
Methods

5

Chapter 6 Window

This chapter deals with the Window object and the client-side objects associated with
it: Frame, Location, and History.

Window
Properties
Methods

Frame
Location
Properties
Methods

History
Properties
Methods

screen
Properties

Chapter 7 Form

This chapter deals with the use of forms, which appear within a document to obtain
input from the user.

Form
Properties
Methods

Hidden
Properties

Text
Properties
Methods

Textarea
Properties
Methods

Password
Properties
Methods

FileUpload
Properties
Methods

6
Button
Properties
Methods

Submit
Properties
Methods

Reset
Properties
Methods

Radio
Properties
Methods

Checkbox
Properties
Methods

Select
Properties
Methods

Option
Properties

Chapter 8 Browser

This chapter deals with the browser and elements associated with it.

navigator
Properties
Methods

MimeType
Properties

Plugin
Properties

Chapter 9 Events and Event Handlers

This chapter contains the event object and the event handlers that are used with client-
side objects in JavaScript to evoke particular actions. In addition, it contains general
information about using events and event handlers.

General Information about Events
Defining Event Handlers
Events in Navigator 4.0

7

event
onAbort
onBlur
onChange
onClick
onDblClick
onDragDrop
onError
onFocus
onKeyDown
onKeyPress
onKeyUp
onLoad
onMouseDown
onMouseMove
onMouseOut
onMouseOver
onMouseUp
onMove
onReset
onResize
onSelect
onSubmit
onUnload

Chapter 10 LiveWire Database Service

This chapter contains the server-side objects associated with LiveWire: database,
DbPool, Connection, Cursor, Stproc, Resultset and blob.

database
Transactions
Properties
Methods

DbPool
Properties
Methods

Connection
Properties
Methods

Cursor
Properties
Methods

Stproc
Properties

8
Methods

Resultset
Properties
Methods

blob
Methods

Chapter 11 Session Management Service

This chapter contains those server-side objects associated with managing a session,
including request, client, project, server, and Lock.

request
Properties

client
Properties
Methods

project
Properties
Methods

server
Properties
Methods

Lock
Methods

Chapter 12 Utilities

This chapter contains the server-side objects File and SendMail.

File
Properties
Methods

SendMail
Properties
Methods

Chapter 13 Global Functions

This chapter contains all JavaScript functions not associated with any object.

addClient
addResponseHeader

9
blob
callC
debug
deleteResponseHeader
escape
eval
flush
getOptionValue
getOptionValueCount
isNaN
Number
parseFloat
parseInt
redirect
registerCFunction
ssjs_generateClientID
ssjs_getCGIVariable
ssjs_getClientID
String
taint
unescape
untaint
write

Chapter 14 Java packages for LiveConnect

netscape.javascript.JSObject
Methods and static methods

netscape.javascript.JSException
Constructors

netscape.plugin.Plugin
Constructors and methods

10
Chapter 1
Introduction
This chapter briefly introduces JavaScript, Netscape's cross-platform, object-based scripting language
for client and server applications.
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.


Client-side JavaScript (or Navigator JavaScript) encompasses the core language plus extras such as
the predefined objects only relevant to running JavaScript in a browser. Server-side JavaScript
encompasses the same core language plus extras such as the predefined objects and functions only
relevant to running JavaScript on a server.
Client-side JavaScript is embedded directly in HTML pages and is interpreted by the browser
completely at runtime. Because production applications frequently have greater performance
demands upon them, JavaScript applications that take advantage of its server-side capabilities are
compiled before they are deployed. The next two sections introduce you to how JavaScript works on
the client and on the server.
Client-Side JavaScript
Web browsers such as Netscape Navigator 2.0 (and later versions) can interpret client-side JavaScript
statements embedded in an HTML page. When the browser (or client) requests such a page, the

11
server sends the full content of the document, including HTML and JavaScript statements, over the
network to the client. The client reads the page from top to bottom, displaying the results of the
HTML and executing JavaScript statements as it goes. This process produces the results that the user
sees and is illustrated in Figure 1.2.

Figure 1.2 Client-side JavaScript.

Client-side JavaScript statements embedded in an HTML page can respond to user events such as
mouse clicks, form input, and page navigation. For example, you can write a JavaScript function to
verify that users enter valid information into a form requesting a telephone number or zip code.
Without any network transmission, the embedded JavaScript on the HTML page can check the
entered data and display a dialog box to the user who enters invalid data.
Server-Side JavaScript
On the server, JavaScript is also embedded in HTML pages. The server-side statements can connect
to relational databases from different vendors, share information across users of an application, access
the file system on the server, or communicate with other applications through LiveConnect and Java.
A compiled JavaScript application can also include client-side JavaScript in addition to server-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.

12

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.

In contrast to standard Common Gateway Interface (CGI) programs, all JavaScript is integrated
directly into HTML pages, facilitating rapid development and easy maintenance. JavaScript's Session
Management Service contains objects you can use to maintain data that persists across client requests,
multiple clients, and multiple applications. JavaScript's LiveWire Database Service provides objects
for database access that serve as an interface to Structured Query Language (SQL) database servers.

13
JavaScript Objects
JavaScript has predefined objects for the core language, as well as additions for client-side and
server-side JavaScript.
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 ar

Преглед на първите от 396 страници - останалите след изтегляне

Описание

Дисциплина: Мобилни интернет системи

0 коментара

Все още няма коментари. Бъдете първият, който ще коментира.

За да коментирате, трябва да сте влезли в профила си.

Влезте