Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
27 views

Javascript Object Reference: Objects

JavaScript has many built-in objects that can be used for programming. This document provides a reference for many common JavaScript objects like Array, Date, and document. It lists the properties and methods for each object to make programming with them easier. Some key objects covered include Anchor, Applet, Array, Boolean, Button, Date, and document.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Javascript Object Reference: Objects

JavaScript has many built-in objects that can be used for programming. This document provides a reference for many common JavaScript objects like Array, Date, and document. It lists the properties and methods for each object to make programming with them easier. Some key objects covered include Anchor, Applet, Array, Boolean, Button, Date, and document.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 19

JavaScript Object Reference

JavaScript has a wide variety of objects you can use when programming, and
each of them have different properties you can control or display through the use
of methods. This table should make your programming jobs in JavaScript a little
easier.

Objects
Anchor
Applet
Array
Boolean
Button
Checkbox
Date
document
event
FileUpload
form

Frame
Function
Hidden
History
Image
Java
JavaArray
JavaClass
JavaObject
JavaPackage
Layer
Link

Location
Math
MimeType
Navigator
netscape
Number
Object
Option
Packages
Password
Plugin
Radio

RegExp
Reset
screen
Select
String
Style
Submit
Sun
Text
Textarea
window

JavaScript Object Reference - Anchor


An anchor is a place in the page that is the target of a link.

Anchor
Properties
Name

Description

Ver.

name

Specifies the anchor's name.

1.2

text

Specifies the text of an anchor.

1.2

Pixels from the left edge of the document.

1.2

Pixels from the top edge of the document.

1.2

JavaScript Object Reference - Applet

Applet
Properties
Name

Description

Ver.

The Applet object inherits all public properties of the Java applet.
Methods
Name

Description

Ver.

The Applet object inherits all public methods of the Java applet.

JavaScript Object Reference - Array


An array is a list of elements indexed sequentially starting at zero. JavaScript
array elements, as with their variables, can be of differing types.

Array
Properties
Name

Description

constructor The function that creates and object's


prototype.

Ver.
1.1

index

Reflects original string against what the regular 1.1


expression matched.

input

For an array created by a regular expression


match, reflects the original string against that
which the regular expression was matched.

1.1

length

The number of elements in an array.

1.3

prototype

Allows the addition of properties to all objects.

1.1

Name

Description

Ver.

concat

Combines two arrays and returns a new array.

1.1

join

Joins all elements of an array into a string.

1.1

pop

Removes the last element from an array and


returns that element.

1.1

push

Adds elements to the end of an array and


returns the array's length.

1.3

reverse

Makes the first element the last and vise-versa. 1.1

shift

Takes away 1st element and returns the


element.

Methods

1.1

slice

Takes a section out of an array and returns a


new array.

1.1

splice

Adds or removes elements in an array.

1.3

sort

Sorts the elements in an array.

1.1

toSource

Used to to create a new array. Overrides the


Object.toSource method.

1.3

toString

Returns a string representing the array and its


elements. Overrides the Object.toString
method.

1.1

unshift

Adds elements to the front of the array and


returns its new length.

1.1

valueOf

Returns the primitive value of the array.


Overrides the Object.valueOf method.

1.1

JavaScript Object Reference - Boolean


Boolean
Properties
Name

Description

constructor Specifies the function that creates an object's


prototype.
prototype

Ver.
1.1

Defines a property that is shared by all Boolean 1.1


objects.

Methods
Name

Description

Ver.

toSource

Use this value to create a new object. Overrides 1.3


the Object.toSource method.

toString

Returns a string representing the defined


object. Overrides the Object.toString method.

valueOf

Returns the primitive value of a Boolean object. 1.1


Overrides the Object.valueOf method.

1.1

JavaScript Object Reference - Button


Button
Properties
Name

Description

Ver.

form

Defines what form contains the button object. 1.0

name

Name of the button.

1.0

type

Type of the button.

1.1

value

Value of the form.

1.0

Name

Description

Ver.

blur

Takes focus off the button.

1.1

click

Simulates a mouse click on the button.

1.0

focus

Puts focus on the button.

1.1

Methods

handleEvent Invokes the handler for the specified event.

1.2

JavaScript Object Reference - Checkbox


Checkbox
Properties
Name

Description

Ver.

checked

Boolean property that reflects the state of


the checkbox.

1.0

defaultChecked Boolean property that reflects the


CHECKED attribute.

1.0

form

Defines what form contains the button


object.

1.0

name

Name of the button.

1.0

type

Type of the button.

1.1

value

Value of the form.

1.0

Name

Description

Ver.

blur

Takes focus off the button.

1.1

click

Simulates a mouse click on the button.

1.0

focus

Puts focus on the button.

1.1

handleEvent

Invokes the handler for the specified event. 1.2

Methods

JavaScript Object Reference - Date


Date
Date
Name

Description

Ver.

constructor

Specifies function that creates an


object's prototype.

1.0

prototype

Allows additional properties to a Date


object.

1.0

Methods

Name

Description

Ver.

getDate

Returns day of the month from your


local time.

1.0

getDay

Returns day of the week from your


local time.

1.0

getFullYear

Returns the year from your local time.

1.3

getHours

Returns the hour from your local time.

1.0

getMilliseconds

Returns the milliseconds from your


local time.

1.3

getMinutes

Returns the minutes from your local


time.

1.0

getMonth

Returns the month from your local


time.

1.0

getSeconds

Returns the seconds from your local


time.

1.0

getTime

Returns the numeric value for the time 1.0


from your local time.

getTimezoneOffset

Returns the time-zone offset in


minutes from your local time.

getUTCDate

Returns day of the month according to 1.3


universal time.

getUTCDay

Returns day of the week according to


universal time.

1.3

getUTCFullYear

Returns the year according to


universal time..

1.3

getUTCHours

Returns the hour according to


universal time..

1.3

1.0

getUTCMilliseconds Returns the milliseconds according to


universal time..

1.3

getUTCMinutes

Returns the minutes according to


universal time..

1.3

getUTCMonth

Returns the month according to


universal time..

1.3

getUTCSeconds

Returns the seconds according to


universal time..

1.3

getYear

Returns the date from your local time.

1.0

parse

Number of milliseconds in a date string 1.0


since January 1, 1970, 00:00:00, local
time.

setDate

Sets the day of the month from your


local time.

1.0

setFullYear

Sets the year from your local time.

1.3

setHours

Sets the hour from your local time.

1.0

setMilliseconds

Sets the milliseconds from your local


time.

1.3

setMinutes

Sets the minutes from your local time.

1.0

setMonth

Sets the month from your local time.

1.0

setSeconds

Sets the seconds from your local time. 1.0

setTime

Sets the numeric value for the time


from your local time.

1.0

setUTCDate

Sets day of the month according to


universal time.

1.3

setUTCFullYear

Sets the year according to universal


time..

1.3

setUTCHours

Sets the hour according to universal


time..

1.3

setUTCMilliseconds Sets the milliseconds according to


universal time..

1.3

setUTCMinutes

Sets the minutes according to


universal time..

1.3

setUTCMonth

Sets the month according to universal


time..

1.3

setUTCSeconds

Sets the seconds according to


universal time..

1.3

setYear

Sets year for a specified date from


your local time.

1.3

toGMTString

Converts a date to a string, using the


Internet GMT conventions.

1.0

toLocaleString

Converts a date to a string, using the


current location's conventions.

1.0

toSource

Use this value to create a new object. 1.3


Overrides the Object.toSource method.

toString

Returns a string representing the


specified Date object. Overrides the
Object.toString method.

1.0

toUTCString

Converts a date to a string, using the


universal time convention.

1.0

UTC

Returns the number of milliseconds in

1.0

a Date object since January 1, 1970,


00:00:00, universal time.
valueOf

Returns the primitive value of a Date


object. Overrides the Object.valueOf
method.

1.0

JavaScript Object Reference - document


document
Properties
Name

Description

Ver.

alinkColor

Specifies the ALINK attribute.

1.0

anchors

Contains an entry for each anchor in the


document.

1.0

applets

Array that contains an entry for each applet


in the document.

1.1

bgColor

A string that specifies the BGCOLOR


attribute.

1.0

classes

Creates a Style object that can specify a


specific CLASS attribute.

1.2

cookie

Specifies a cookie.

1.0

domain

Specifies the domain name of the server


that served a document.

1.0

embeds

An array containing an entry for each plug-in 1.1


in the document.

fgColor

A string that specifies the TEXT attribute.

formName

A separate property for each named form in 1.1


the document.

forms

An array a containing an entry for each form 1.1


in the document.

height

The height of the document, in pixels.

1.0

ids

Creates a Style object that can specify the


style of individual HTML tags.

1.2

images

An array containing an entry for each image 1.0


in the document.

lastModified

A string that specifies the date the document 1.0


was last modified.

layers

Array containing an entry for each layer


within the document.

1.2

linkColor

A string that specifies the LINK attribute.

1.0

1.0

links

An array containing an entry for each link in


the document.

1.0

plugins

An array containing an entry for each plug-in 1.1


in the document.

referrer

A string that specifies the URL of the calling 1.0


document.

tags

Creates a Style object that can specify the


styles of HTML tags.

1.2

title

A string that specifies the contents of the


TITLE tag.

1.0

URL

A string that specifies the complete URL of a 1.0


document.

vlinkColor

A string that specifies the VLINK attribute.

1.0

width

The width of the document, in pixels.

1.0

Description

Ver.

Methods
Name

captureEvents Sets the document to capture all events of


the specified type.

1.2

close

Closes an output stream and forces data to


display.

1.0

contextual

Uses selection criteria to specify a Style


object that can set the style of HTML tags.

1.2

getSelection

Returns a string containing the text of the


selection.

1.2

handleEvent

Invokes the handler for the specified event.

1.2

open

Opens a stream to collect the output of write 1.0


or writeln methods.

releaseEvents Sets the window or document to release


captured events of the specified type,
sending the event to objects further along
the event hierarchy.

1.2

routeEvent

Passes a captured event along the normal


event hierarchy.

1.2

write

Writes HTML expressions to a document in


the specified window.

1.0

writeln

Writes HTML expressions to a document in


the specified window and follows them with
a newline character.

1.0

JavaScript Object Reference - event

event
Properties
Name

Description

data

Passes an array of strings containing the URLs of 1.2


the dropped objects to the DragDrop event.

height

Represents the height of the window or frame.

layerX

Number specifying either the object width when


1.2
passed with the resize event, or the cursor's
horizontal position in pixels relative to the layer in
which the event occurred.

layerY

Number specifying either the object height when


passed with the resize event, or the cursor's
vertical position in pixels relative to the layer in
which the event occurred.

modifiers String specifying the modifier keys associated


with a mouse or key event.

Ver.

1.2

1.2

1.2

pageX

Number specifying the cursor's horizontal position 1.2


in pixels on the page.

pageY

Number specifying the cursor's vertical position in 1.2


pixels on the page.

screenX

Number specifying the cursor's horizontal position 1.2


in pixels on the screen.

screenY

Number specifying the cursor's vertical position in 1.2


pixels on the screen.

target

String representing the object to which the event


was originally sent.

which

Number specifying either the mouse button that


1.2
was pressed or the ASCII value of a pressed key.
For a mouse, 1 is the left button, 2 is the middle
button, and 3 is the right button.

width

The width of the window or frame.

1.2

layerX.

1.2

layerY.

1.2

1.2

1.2

JavaScript Object Reference - FileUpload


FileUpload
Properties
Name

Description

Ver.

form

Specifies the form containing the FileUpload


object.

1.0

name

NAME attribute of the form.

1.0

type

TYPE attribute of the form.

1.1

value

Reflects the current value of the file upload


element's field.

1.0

Name

Description

Ver.

blur

Takes focus off the object.

1.0

focus

Puts focus on the object.

1.0

Methods

handleEvent Invokes the handler for the event.

1.2

select

1.0

Selects the input area of the file upload field.

JavaScript Object Reference - form


form
Properties
Name

Description

Ver.

action

ACTION attribute.

1.0

elements

An array reflecting all the elements in a form.

1.0

encoding

ENCTYPE attribute.

1.0

length

Reflects the number of elements on a form.

1.0

method

METHOD attribute.

1.0

name

NAME attribute.

1.0

target

TARGET attribute.

1.0

Description

Ver.

Methods
Name

handleEvent Invokes the handler for the specified event.

1.2

reset

Simulates a mouse click on a reset button for


the calling form.

1.1

submit

Submits a form.

1.0

JavaScript Object Reference - Frame


Frame
Properties
Name

Description

Ver.

closed

Specifies whether a window has


been closed or not.

1.1

crypto

An object which allows access to


encryption features.

1.2

defaultStatus

Default message displayed in the


browser's status bar.

1.0

document

Information on the document,


provides methods for displaying
HTML output to the user.

1.0

frames

An array that reflects all the frames 1.0


in a window.

history

Contains information on the URLs


that the client has visited within a
window.

innerHeight

Specifies the vertical dimension, in 1.2


pixels, of the window's content
area.

innerWidth

Specifies the horizontal dimension, 1.2


in pixels, of the window's content
area.

length

The number of frames in the


window.

1.0

location

Information on the current URL.

1.0

locationbar

Browser window's location bar.

1.2

menubar

Browser window's menu bar.

1.2

name

Unique name used to refer to this


window.

1.0

offscreenBuffering

Specifies whether updates to a


window are performed in an
offscreen buffer.

1.2

opener

Specifies the window name of the 1.1


calling document when a window is
opened using the open method.

outerHeight

Specifies the vertical dimension, in 1.2


pixels, of the window's outside
boundary.

outerWidth

Specifies the horizontal dimension, 1.2


in pixels, of the window's outside
boundary.

pageXOffset

Provides the current x-position, in 1.2


pixels, of a window's viewed page.

pageYOffset

Provides the current y-position, in 1.2


pixels, of a window's viewed page.

1.1

parent

A synonym for a window or frame


whose frameset contains the
current frame.

1.0

personalbar

Represents the browser window's


personal bar (also called the
directories bar).

1.2

screenX

Specifies the x-coordinate of the


left edge of a window.

1.2

screenY

Specifies the y-coordinate of the


top edge of a window.

1.2

scrollbars

Represents the browser window's


scroll bars.

1.2

self

Refers to the current window.

status

Specifies a priority or transient


message in the window's status
bar.

statusbar

Represents the browser window's


status bar.

toolbar

Represents the browser window's


toolbar.

top

Refers to the topmost browser


window.

window

Refers to the current window.

Methods
Name

Description

alert

Displays an Alert dialog box with a


message and an OK button.

atob

Decodes a string of data which has


been encoded using base-64
encoding.

back

Undoes the last history step in any


frame within the top-level window.

blur

Removes focus from the specified


object.

btoa

Creates a base-64 encoded string.

captureEvents

Sets the window or document to


capture all events of the specified
type.

clearInterval

Cancels a timeout that was set with


the setInterval method.

Ver.

clearTimeout

Cancels a timeout that was set with


the setTimeout method.

close

Closes the specified window.

confirm

Displays a Confirm dialog box with


the specified message and OK and
Cancel buttons.

crypto.random

Returns a pseudo-random string


whose length is the specified
number of bytes.

crypto.signText

Returns a string of encoded data


which represents a signed object.

disableExternalCapture Disables external event capturing


set by the enableExternalCapture
method.
enableExternalCapture Allows a window with frames to
capture events in pages loaded
from different locations (servers).
find

Finds the specified text string in the


contents of the specified window.

focus

Gives focus to the specified object.

forward

Loads the next URL in the history


list.

handleEvent

Invokes the handler for the


specified event.

home

Points the browser to the URL


specified in preferences as the
user's home page.

moveBy

Moves the window by the specified


amounts.

moveTo

Moves the top-left corner of the


window to the specified screen
coordinates.

open

Opens a new web browser window.

print

Prints the contents of the window or


frame.

prompt

Displays a Prompt dialog box with


a message and an input field.

releaseEvents

Sets the window to release


captured events of the specified
type, sending the event to objects
further along the event hierarchy.

resizeBy

Resizes an entire window by


moving the window's bottom-right
corner by the specified amount.

resizeTo

Resizes an entire window to the


specified outer height and width.

routeEvent

Passes a captured event along the


normal event hierarchy.

scroll

Scrolls a window to a specified


coordinate.

scrollBy

Scrolls the viewing area of a


window by the specified amount.

scrollTo

Scrolls the viewing area of the


window to the specified
coordinates, such that the specified
point becomes the top-left corner.

setHotKeys

Enables or disables hot keys in a


window which does not have
menus.

setInterval

Evaluates an expression or calls a


function every time a specified
number of milliseconds elapses.

setResizable

Specifies whether a user is


permitted to resize a window.

setTimeout

Evaluates an expression or calls a


function once after a specified
number of milliseconds has
elapsed.

setZOptions

Specifies the z-order stacking


behavior of a window.

stop

Stops the current download.

JavaScript Object Reference - Function


Function
Properties
Name

Description

arguments

The array of arguments passed to the function. 1.1

arity

Specifies the number of arguments a functions


expects.

constructor Specifies the function that creates an object's


prototype.

Ver.
1.2
1.1

length

Specifies the number of arguments expected by 1.1


the function.

prototype

Allows the addition of properties to a function


object.

1.1

Name

Description

Ver.

apply

Allows you to apply a method of another object 1.3


in the context of a different object.

call

Allows you to execute a method of another


object in the context of a different object.

1.3

toSource

Returns a string representing the source code


of the function.

1.3

toString

Returns a string representing the source code


of the function.

1.1

valueOf

Returns a string representing the source code


of the function.

1.1

Methods

JavaScript Object Reference - Hidden


Hidden
Properties
Name

Description

Ver.

form

Specifies the form containing the Hidden object.

1.0

name

Reflects the NAME attribute.

1.1

type

Reflects the TYPE attribute.

1.1

value

Reflects the current value of the Hidden object.

1.0

JavaScript Object Reference - History


History
Properties
Name

Description

Ver.

current

Specifies the URL of the current history entry.

1.1

length

Reflects the number of entries in the history list.

1.0

Next

Specifies the URL of the next history entry.

1.1

previous Specifies the URL of the previous history entry.

1.1

Methods
Name

Description

Ver.

back

Loads the previous URL in the history list.

1.0

forward

Loads the next URL in the history list.

1.0

Go

Loads a URL from the history list.

1.0

JavaScript Object Reference - Image


Image
Properties
Name

Description

Ver.

border

Reflects the BORDER attribute.

1.1

complete

Boolean value indicating whether the web


1.1
browser has completed its attempt to load the
image.

height

Reflects the HEIGHT attribute.

1.1

hspace

Reflects the HSPACE attribute.

1.1

lowsrc

Reflects the LOWSRC attribute.

1.1

name

Reflects the NAME attribute.

1.1

Src

Reflects the SRC attribute.

1.1

vspace

Reflects the VSPACE attribute.

1.1

width

Reflects the WIDTH attribute.

1.1

Description

Ver.

Methods
Name

handleEvent Invokes the handler for the specified event.

1.1

JavaScript Object Reference - Java


Java
Properties
Methods
The java object is a top-level, predefined JavaScript object.
You can automatically access it without using a constructor or
calling a method.

JavaScript Objects
This is a table of the most commonly used JavaScript objects, with all of their properties,
methods, and event handlers.

For additional information on JavaScript:

Visit Netscape's JavaScript Documentation, which has a complete listing of these


objects as well as loads of other information on the JavaScript spec.

Hierarchy Objects
Object

Properties

Methods

Event Handlers

Window

defaultStatus
frames
opener
parent
scroll
self
status
top
window

alert
blur
close
confirm
focus
open
prompt
clearTimeout
setTimeout

onLoad
onUnload
onBlur
onFocus

Frame

defaultStatus
frames
opener
parent
scroll
self
status
top
window

alert
none (The onLoad and onUnload
blur
event handlers belong to the Window
close
object)
confirm
focus
open
prompt
clearTimeout
setTimeout

Location

hash
host
hostname
href
pathname
por
protocol
search

reload
replace

none

History

length
forward
go

back

none

Navigator appCodeName javaEnabled


appName
appVersion
mimeTypes
plugins

none

userAgent
document alinkColor
anchors
applets
area
bgColor
cookie
fgColor
forms
images
lastModified
linkColor
links
location
referrer
title
vlinkColor

clear
close
open
write
writeln

none (the onLoad and onUnload


event handlers belong to the Window
object.

image

border
complete
height
hspace
lowsrc
name
src
vspace
width

none

none

form

action
elements
encoding
FileUpload
method
name
target

submit
reset

onSubmit
onReset

text

defaultValue
name
type
value

focus
blur
select

onBlur
onCharge
onFocus
onSelect

Built-in Objects
Array

length

join
reverse
sort xx

none

Date

none

getDate
getDay
getHours
getMinutes
getMonth
getSeconds
getTime
getTimeZoneoffset
getYear
parse
prototype
setDate
setHours
setMinutes
setMonth
setSeconds
setTime
setYear
toGMTString
toLocaleString
UTC

none

String

length
prototype

anchor
big
blink
bold
charAt
fixed
fontColor
fontSize
indexOf
italics
lastIndexOf
link
small
split
strike
sub
substring
sup
toLowerCase
toUpperCase

Window

You might also like