Fjas;dlkfjas;dlfjas



[cn]Appendix A

[ct]A Brief JavaScript and JScript Object Reference

An object is a construct such as a document, frame, file, folder, or drive that manages its own properties and provides functions known as methods that can be used to control the object or its data.

Both JavaScript and JScript support a wide range of objects. Both provide access to a core set of built-in objects. In addition, other collections of objects are provided by the execution environments in which the two scripting languages operate. The collections of objects supported by JavaScript include:

***Begin Bulleted List***

[bl] Built-in JavaScript objects

[bl] Browser-based objects

[bl] User-defined objects

***End Bulleted List***

The collections of objects supported by JScript include:

***Begin Bulleted List***

[bl] Built-in JScript objects

[bl] Core objects

[bl] Runtime objects

[bl] User-defined objects

***End Bulleted List***

An object’s properties are the attributes of the object and contain stored values that represent some quality of the object (such as the object's name).

Object properties are referenced using the following syntax:

Objectname.property

An object’s methods can be executed in a similar manner using the following syntax:

Objectname.method(p1, p2,...pn)

This appendix provides a quick reference to JavaScript’s built-in core objects as well as major browser-based objects. In addition, JScript’s core and runtime objects are covered as well.

***Begin Note***

Because of the sheer number of properties and methods supported by JavaScript and JScript, there is not enough room in this book to define each of the properties and methods associated with all of the objects defined in this appendix.

More detailed information about these objects and their properties and methods can be found in the text of this book. In addition, you can get detailed information about any JavaScript property or method from . This Web page provides links to online copies of Netscape’s JavaScript reference manuals and guides. Similarly, you can get detailed information on every method and property supported by JScript by visiting Microsoft’s scripting Web site at msdn.scripting.

***End Note***

[1]JavaScript’s Core Objects

JavaScript provides access to a collection of built-in or core objects. These objects provide access to collections of related properties and methods. Table A.1 provides an overview of JavaScript's major core objects and lists their associated properties and methods.

***Begin Table***

Table A.1

Core JavaScript Objects and Their Properties and Methods

Object Description

Array Provides for the creation and management of arrays.

Properties: constructor, index, input, length, prototype.

Methods: concat(), join(), pop(), push(), reverse(), shift(), slice(), splice(), sort(), toSource(), toString(), unshift(), valueOf().

Boolean Provides for the creation of a Boolean value.

Properties: constructor, prototype.

Methods: toSource(), toString(), valueOf().

Date Provides access to date and time methods.

Properties: constructor, prototype.

Methods: getDate(), getDay(), getFullYear(), getHours(), getMilliseconds(), getMinutes(), getMonth(), getSeconds(), getTime(), getTimezoneOffset(), getUTCDate(), getUTCDay(), getUTCFullYear(), getUTCHours(), getUTCMilliseconds(), getUTCMinutes(), getUTCMonth(), getUTCSeconds(), getYear(), parse(), setDate(), setFullYear(), setHours(), setMilliseconds(), setMinutes(), setMonth(), setSeconds(), setTime(), setUTCDate(), setUTCFullYear(), setUTCHours(), setUTCMilliseconds(), setUTCMinutes(), setUTCMonth(), setUTCSeconds(), setYear(), toGMTString(), toLocaleString(), toSource(), toString(), toUTCString(), UTC(), ValueOf().

Function Provides the capability to create a function.

Properties: arguments, arguments.callee, arguments.caller, arguments.length, arity, constructor, length, prototype.

Methods: apply(), call(), toSource(), toString(), valueOf().

Math Provides access to mathematical functions and constants.

Properties: E, LN10, LN2, LOG10E, LOG2E, PI, SQRT1, SQRT2.

Methods: abs(), acos(), asin(), atan(), ceil(), cos(), exp(), floor(), Log(), Max(), Min(), Pow(), Random(), Round(), Sin(), Sqrt(), Tan().

Number Provides access to a collection of numeric constants.

Properties: constructor, MAX_VALUE, MIN_VALUE, NaN, NEGATIVE_INFINITY, POSITIVE_INFINITY, prototype.

Methods: toSource(), toString(), valueOf().

RegExp Saves information from regular expressions.

Properties: $1...$9, $, $*, $&, $+, $', $', constructor, global, ignoreCase, input, lastIndex, lastMatch, lastParen, leftContext, multiline, prototype, rightContext, source.

Methods: compile(), exec(), test(), toSource(), toString(), valueOf().

String Provides the capability to manipulate strings.

Properties: constructor, length, prototype.

Methods: anchor(), big(), blink(), bold(), charAt(), charCodeAt(), concat(), fixed(), fontcolor(), fontsize(), fromCharCode(), indexOf(), italics(), lastIndexOf(), link(), match(), replace(), search(), slice(), small(), split(), strike(), sub(), substr(), substring(), sup(), toLowerCase(), toSource(), toString(), toUpperCase(), valueOf().

***End Table***

[1]JavaScript Browser-Based Objects

When executed inside the browser, JavaScript provides access to a collection of objects that represent the contents of HTML pages. Each of these objects provides access to properties and methods that enable JavaScript to access and manipulate HTML pages and their contents. Table A.2 provides an overview of the major browser-based objects and lists their associated properties and methods.

***Begin Table***

Table A.2

JavaScript Browser-Based Objects and Their Properties and Methods

Object Description

Anchor Represents a location in a Web page that is the target of a link.

Properties: name, text, x, y.

Methods: N/A.

Area A type of link object that provides access to an area in an imagemap.

Properties: hash, host, hostname, href, pathname, port, protocol, search, target.

Methods: N/A.

Button A representation of a button on a form that has its own methods and properties and that is subject to various events.

Properties: form, name, type, value.

Methods: blur(), click(), focus(), handleEvent().

Checkbox A representation of a check box on a form. The object has its own methods and properties and is subject to various events.

Properties: checked, defaultChecked, form, name, type, value.

Methods: blur(), click(), focus(), handleEvent().

Document An object that provides access to the document that is currently loaded into a browser window and whose properties and methods provide access to viewing and changing the page content.

Properties: alinkColor, anchors, applets, byColor, classes, cookie, domain, embeds, fgColor, formName, forms, height, ids, images, lastModified, layers, linkColor, links, plugins, referrer, tags, title, URL, vlinkColor, width.

Methods: captureEvents(), close(), contextual(), getSelection(), handleEvent(), open(), releaseEvents(), routeEvent(), write(), writeln().

Event An object that provides access to properties that describe an event.

Properties: data, height, layerX, layerY, modifiers, pageX, pageY, screenX, screenY, target, type, which, width, X, Y.

Methods: N/A.

FileUpload An object that represents the file upload HTML element.

Properties: form, name, type, value.

Methods: blur(), focus(), handleEvent(), select().

Form An object created by the HTML tag that provides access to all the elements on a form.

Properties: action, elements, encoding, length, method, name, target.

Methods: handleEvent(), reset(), submit().

Hidden A text-based object that is not displayed on a form but that can be accessed programmatically.

Properties: form, name, type, value.

Methods: N/A.

History An array containing information about all the URLs that have been loaded into the browser window.

Properties: current, length, next, previous.

Methods: back(), forward(), go().

Image An object created by the HTML tag that provides access to image attributes.

Properties: border, complete, height, hspace, lowsrc, name, src, vspace, width.

Methods: handleEvent().

Layer An object that represents an HTML layer.

Properties: above, background, bgColor, below, clip.bottom, clip.height, clip.left, clip.right, , clip.width, document, left, name, pageX, pageY, parentLayer, siblingAbove, siblingBelow, src, top, visibility, window, x, y, zIndex.

Methods: captureEvents(), handleEvent(), load(), moveAbove(), moveBelow(), moveBy(), moveTo(), moveToAbsolute(), releaseEvents(), resizeBy(), resizeTo(), routeEvent().

Link An object that represents an HTML hypertext link.

Properties: hash, host, hostname, href, pathname, port, protocol, search, target, text, x, y.

Methods: handleEvent().

Location An object that provides access to the window object's location property.

Properties: hash, host, hostname, href, pathname, port, protocol, search.

Methods: reload(), replace().

MimeType A predefined JavaScript object that provides access to a specific browser-supported MIME type.

Properties: description, enabledPlugin, suffixes, type.

Methods: N/A.

Navigator An object that provides access to the information about the version of Netscape Navigator supported by the browser.

Properties: appCodeName, appName, appVersion, language, mimeTypes, platform, plugins, userAgent.

Methods: javaEnabled(), plugins.refresh(), preference(), savePreferences(), taintEnabled().

Object A root object from which all objects are derived.

Properties: constructor, prototype.

Methods: eval(), toSource(), toString(), unwatch(), valueOf(), watch().

Option An object created by the HTML tag that provides access to the list of options in a select list.

Properties: defaultSelected, index, length, selected, text, value.

Methods: N/A.

Password An object created by the HTML tag's TYPE="password" option that represents a form's password field.

Properties: defaultValue, form, name, type, value.

Methods: blur(), focus(), handleEvent(), select().

Plugin An object whose properties represent all the browser's plug-ins.

Properties: description, filename, length, name.

Methods: N/A.

Radio A representation of a radio button on a form.

Properties: checked, defaultChecked, form, name, type, value.

Methods: blur(), click(), focus(), handleEvent().

Reset A specialized type of button object that has its own methods and properties.

Properties: form, name, type, value.

Methods: blur(), click(), focus(), handleEvent().

Screen An object that contains information about the current screen display.

Properties: availHeight, availLeft, availTop, availWidth.

Methods: N/A.

Select An object created by the HTML tag that provides access to a form's select list.

Properties: form, length, name, options, selectedIndex, type.

Methods: blur(), focus(), handleEvent().

Style An object that describes the style used by HTML elements and whose properties provide access to specific style attributes.

Properties: align, backgroundColor, backgroundImage, borderBottomWidth, borderColor, borderLeftWidth, borderRightWidth, borderStyle, borderTopWidth, clear, color, display, fontFamily, fontSize, fontStyle, fontWeight, lineHeight, listStyleType, marginBottom, marginLeft, marginRight, marginTop, paddingBottom, paddingLeft, paddingRight, paddingTop, textAlign, textDecoration, textIndent, textTransform, whiteSpace, width.

Methods: borderWidths(), margins(), paddings().

Submit A specialized type of button object on a form that has its own methods and properties.

Properties: form, name, type, value.

Methods: blur(), click(), focus(), handleEvent().

Text A representation of a single-line text field on a form that has its own methods and properties.

Properties: defaultValue, form, name, type, value.

Methods: blur(), focus(), handleEvent(), select().

Textarea A representation of a multiline text box on a form that has its own methods and properties.

Properties: defaultValue, form, name, type, value.

Methods: blur(), focus(), handleEvent(), select().

Window An object that represents a browser window or frame and whose methods can be used to control the window or frame.

Properties: closed, crypto, defaultStatus, document, frames, history, innerHeight, innerWidth, length, location, locationbar, menubar, name, offscreenBuffering, opener, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, personalbar, screenX, screenY, scrollbars, self, status, statusbar, toolbar, top, window.

Methods: alert(), atob(), back(), blur(), btoa(), captureEvents(), clearInterval(), clearTimeout(), close(), confirm(), crypto.random(), crypto.signText(), disableExternalCapture(), find(), focus(), forward(), handleEvent(), home(), moveBy(), moveTo(), open(), print(), prompt(), releaseEvents(), resizeBy(), resizeTo(), routeEvent(), scroll(), scrollBy(), scrollTo(), setHotKeys(), setInterval(), setResizable(), setTimeout(), setZOptions(), stop().

***End Table***

[1]JScript Core Objects

Like JavaScript, JScript provides its own collection of built-in or core objects. Each of these objects provides access to a unique collection of properties and methods. Table A.3 provides an overview of JScript’s core objects and lists their associated properties and methods.

***Begin Table***

Table A.3

Core JScript Objects and Their Properties and Methods

Object Description

ActiveXObject Provides a reference to an automation object.

Properties: N/A.

Methods: N/A.

Array Provides for the creation and management of arrays.

Properties: constructor, length, prototype.

Methods: concat, join, pop, push, reverse, shift, slice, sort, splice, toLocaleString, toString, unshift, valueOf.

Arguments Represents the arguments passed to the currently executing function.

Properties: 0...n, callee, length.

Methods: N/A.

Boolean Provides for the creation of a Boolean value.

Properties: constructor, prototype.

Methods: toString, valueOf.

Date Provides access to date and time methods.

Properties: constructor, prototype.

Methods: getDate, getDay, getFullYear, getHours, getMilliseconds, getMinutes, getMonth, getSeconds, getTime, getTimezoneOffset, getUTCDate, getUTCDay, getUTCFullYear, getUTCHours, getUTCMilliseconds, getUTCMinutes, getUTCMonth, getUTCSeconds, getVarDate, getYear, setDate, setFullYear, setHours, setMilliseconds, setMinutes, setMonth, setSeconds, setTime, setUTCDate, setUTCFullYear, setUTCHours, setUTCMilliseconds, setUTCMinutes, setUTCMonth, setUTCSeconds, setYear, toGMTString, toLocaleString, toUTCString, toString, valueOf, parse, UTC method.

Enumerator Provides the capability to enumerate a collection of items.

Properties: N/A.

Methods: atEnd, item, moveFirst, moveNext.

Error Provides access to script error information.

Properties: description, number.

Methods: N/A.

Function Provides the capability to create a function.

Properties: arguments, caller, constructor, prototype.

Methods: toString, valueOf.

Global Collects global methods into one object.

Properties: Infinity, NaN.

Methods: escape, eval, isFinite, isNaN, parseFloat, parseInt, unescape.

Math Provides access to mathematical functions and constants.

Properties: E, LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2.

Methods: abs, acos, asin, atan, atan2, ceil, cos, exp, floor, log, max, min, pow, random, round, sin, sqrt, tan.

Number Provides access to a collection of numeric constants.

Properties: MAX_VALUE, MIN_VALUE, NaN, NEGATIVE_INFINITY, POSITIVE_INFINITY, constructor, prototype.

Methods: toLocaleString, toString, valueOf.

Object Provides the capability to create an instance of any other object type.

Properties: prototype, constructor.

Methods: toLocaleString, toString, valueOf.

RegExp Saves information from regular expressions.

Properties: $1...$9, index, input, lastIndex, lastMatch, lastParen, leftContext, rightContext.

Methods: N/A.

Regular Expression Stores a regular expression pattern.

Properties: lastIndex, source.

Methods: compile, exec, test.

String Provides the capability to manipulate strings.

Properties: constructor, length, prototype.

Methods: anchor, big, blink, bold, charAt, charCodeAt, concat, fixed, fontcolor, fontsize, fromCharCode, indexOf, italics, lastIndexOf, link, match, replace, search, slice, small, split, strike, sub, substr, substring, sup, toLowerCase, toUpperCase, toString, valueOf.

VBArray Provides the capability to use VBScript arrays.

Properties: N/A.

Methods: dimensions, getItem, lbound, toArray, ubound.

***End Table***

[1]JScript Runtime Objects

In addition to its collection of built-in or core objects, JScript also provides access to a collection of runtime objects. These runtime objects, listed in Table A.4, provide access to the computer’s file system.

***Begin Table***

Table A.4

JScript Runtime Objects and Their Properties and Methods

Object Description

Dictionary Stores data key, item pairs.

Properties: Count, Item, Key.

Methods: Add (Dictionary), Exists, Items, Keys, Remove, RemoveAll.

Drive Provides access to a disk drive's properties.

Properties: AvailableSpace, DriveLetter, DriveType, FileSystem, FreeSpace, IsReady, Path, RootFolder, SerialNumber, ShareName, TotalSize, VolumeName.

Methods: N/A.

Drives Collection Provides information about system drives.

Properties: Count, Item.

Methods: N/A.

File Provides access to a file's properties.

Properties: Attributes, DateCreated, DateLastAccessed, DateLastModified, Drive, Name, ParentFolder, Path, ShortName, ShortPath, Size, Type.

Methods: Copy, Delete, Move, OpenAsTextStream.

Files Collection Provides access to files contained in a folder.

Properties: Count, Item.

Methods: N/A.

FileSystemObject Provides access to the entire file system.

Properties: Drives.

Methods: BuildPath, CopyFile, CopyFolder, CreateFolder, CreateTextFile, DeleteFile, DeleteFolder, DriveExists, FileExists, FolderExists, GetAbsolutePathName, GetBaseName, GetDrive, GetDriveName, GetExtensionName, GetFile, GetFileName, GetFolder, GetParentFolderName, GetSpecialFolder, GetTempName, MoveFile, MoveFolder, OpenTextFile.

Folder Provides access to a folder's properties.

Properties: Attributes, DateCreated, DateLastAccessed, DateLastModified, Drive, Files, IsRootFolder, Name, ParentFolder, Path, ShortName, ShortPath, Size, SubFolders, Type.

Methods: Copy, Delete, Move, OpenAsTextStream.

Folders Collection Provides access to the folders contained within another folder.

Properties: Count, Item.

Methods: Add (Folders).

TextStream Provides for sequential file access.

Properties: AtEndOfLine, AtEndOfStream, Column, Line.

Methods: Close, Read, ReadAll, ReadLine, Skip, SkipLine, Write, WriteBlankLines, WriteLine.

***End Table***

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches