The following objects are supported in client-side JavaScript, in addition to the core objects.
An Anchor object represents an HTML <anchor> element. Introduced in JavaScript 1.0. Anchor objects can be created either through HTML <A> tags or through the anchor() method of the String object.
In Navigator, the anchor can be referred to by its name.
However, this will not work in Internet Explorer; instead, we must use document.all if we wish to use the anchor's name.
However, this will generate a message in Navigator, so the first method is recommended.
The only property shared by the Anchor object in NN and IE is name.
Property |
Introduced |
Description |
---|---|---|
name |
JavaScript 1.2 |
Indicates the name of the anchor. Corresponds to the name attribute. |
Text |
JavaScript 1.2 |
Specifies the plain text appearing between <a> and </a> of an anchor. |
No methods are shared between the NN and IE Anchor objects.
JscriptJscriptThis object represents a Java applet. Introduced in JavaScript 1.1, Jscript 3.0. Applet objects are created with an HTML <applet> element and referenced through the applets collection of the document object.
The Applet object inherits the public properties of the Java applet.
The Applet object inherits the public methods of the Java applet.
Area objects define an area of an image as an image map; they are a type of Link object. Introduced in JavaScript 1.1, Jscript 3.0.
This object represents an HTML button element. Introduced in JavaScript 1.0, Jscript 1.0. To create a Button object, use the HTML <input> tag with a type attribute equal to "button".
The Button object, in both Netscape Navigator and Internet Explorer, supports the following events:
Property |
Introduced |
Description |
---|---|---|
form |
JavaScript 1.0 |
References the form to which the Button object belongs. |
name |
JavaScript 1.0 |
Indicates the name of the button. Corresponds to the name attribute. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "button". |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
Method |
Introduced |
Description |
---|---|---|
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
click() |
JavaScript 1.0 |
Simulates a mouse-click on the element and fires the onclick event. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
This object also inherits the methods watch() and unwatch() from the Object object.
The Checkbox object represents an HTML checkbox. Introduced in JavaScript 1.0, Jscript 1.0. To create a Checkbox object, use the HTML <input> element with the type attribute set to "checkbox".
The Checkbox object supports the following events:
Property |
Introduced |
Description |
---|---|---|
checked |
JavaScript 1.0 |
Indicates whether the checkbox is currently checked. |
defaultChecked |
JavaScript 1.0 |
Indicates whether the checkbox is checked by default. |
Form |
JavaScript 1.0 |
References the form to which the Checkbox object belongs. |
Name |
JavaScript 1.0 |
Indicates the name of the checkbox. Corresponds to the name attribute. |
Type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "checkbox". |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
Method |
Introduced |
Description |
---|---|---|
Blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
click() |
JavaScript 1.0 |
Simulates a mouse-click on the element and fires the onclick event. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
This object represents the current document. Introduced in JavaScript 1.0, Jscript 1.0. Created with the HTML <body> tag and referenced with the document keyword.
The following events are supported by the document object. However, note that events placed in the <body> tag apply to the window rather than the document object.
Property |
Introduced |
Description |
---|---|---|
alinkColor |
JavaScript 1.0 |
Indicates the color of active links in the document, corresponding to the alink attribute. |
anchors |
JavaScript 1.0 |
Returns an array of the anchor elements in the document. |
applets |
JavaScript 1.1 |
Returns an array of the applet elements in the document. |
bgColor |
JavaScript 1.0 |
Indicates the background color for the document, corresponding to the bgcolor attribute. |
cookie |
JavaScript 1.0 |
Indicates the value of a cookie. |
domain |
JavaScript 1.1 |
Indicates the domain name of the server. |
embeds |
JavaScript 1.1 |
Returns an array of embedded objects in the document. |
fgColor |
JavaScript 1.0 |
Indicates the foreground color for text in the document, corresponding to the text attribute. |
Form_name |
JavaScript 1.1 |
References the named form. |
forms |
JavaScript 1.1 |
Returns an array of the forms in the document. |
images |
JavaScript 1.1 |
Returns an array of the images in the document. |
lastModified |
JavaScript 1.0 |
Indicates when the document was last modified. |
linkColor |
JavaScript 1.0 |
Indicates the default color for links in the document, corresponding to the link attribute. |
links |
JavaScript 1.0 |
Returns an array of the links in the document. |
location |
Deprecated |
Contains the complete URL of the current document. |
Plugins |
JavaScript 1.1 |
Refers to the array of objects representing ActiveX controls or other plug-ins used to display embedded content. |
referrer |
JavaScript 1.0 |
Returns the URL of the document that called the current document. |
title |
JavaScript 1.0 |
Indicates the title of the document, corresponding to the contents of the <title> tag. |
URL |
JavaScript 1.0 |
Returns the URL of the document. |
vlinkColor |
JavaScript 1.0 |
Indicates the color of links that have been visited, corresponding to the vlink attribute. |
Method |
Introduced |
Description |
---|---|---|
Close() |
JavaScript 1.0 |
Closes an output stream and forces data to display. |
open() |
JavaScript 1.0 |
Opens a stream to collect the output of write() or writeln() methods. |
Write() |
JavaScript 1.0 |
Writes a string of HTML to the document. |
writeln() |
JavaScript 1.0 |
Writes a line of HTML to the document. |
The event object represents a JavaScript event. Introduced in JavaScript 1.2, Jscript 3.0. These objects are created automatically when an event occurs, and cannot be created programmatically. We can retrieve a reference to the event by passing event in as a parameter to the event handler.
Not all of these properties are relevant to each event type.
Property |
Introduced |
Description |
---|---|---|
screenX |
JavaScript 1.2 |
Indicates the horizontal position of the mouse pointer, relative to the user's screen. |
screenY |
JavaScript 1.2 |
Indicates the vertical position of the mouse pointer, relative to the user's screen. |
type |
JavaScript 1.2 |
Indicates the type of the current event. |
x |
JavaScript 1.2 |
In Navigator, this indicates the width of the object when passed with the resize event, or the horizontal position of the mouse pointer, relative to the layer in which the event occurred. In IE, it indicates the horizontal position of the mouse pointer relative to the parent element. |
y |
JavaScript 1.2 |
In Navigator, this indicates the height of the object when passed with the resize event, or the vertical position of the mouse pointer, relative to the layer in which the event occurred. In IE, it indicates the vertical position of the mouse pointer relative to the parent element. |
Method |
Introduced |
Description |
---|---|---|
InitEvent( ) |
JavaScript 1.2 |
Initializes Event object properties. |
preventDefault ( ) |
JavaScript 1.2 |
Instructs the web browser to not perform a default action. |
stopPropagation() |
JavaScript 1.2 |
Stops the event from propagating. |
This object represents a file <input> element. Introduced in JavaScript 1.0, Jscript 3.0. Created with an HTML <input> element with the type attribute set to "file".
The FileUpload object supports the following event handlers:
onblur
onfocus
Property |
Introduced |
Description |
---|---|---|
form |
JavaScript 1.0 |
References the form to which the FileUpload object belongs. |
name |
JavaScript 1.0 |
Indicates the name of the FileUpload object. Corresponds to the name attribute. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "file". |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
Method |
Introduced |
Description |
---|---|---|
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
select() |
JavaScript 1.0 |
Selects the input area of the FileUpload object. |
This object represents an HTML form. Introduced in JavaScript 1.0, Jscript 1.0. Form objects are created with the HTML <form> tag and referenced through the forms property of the document object.
The Form object supports two event handlers:
onreset
onsubmit
Property |
Introduced |
Description |
---|---|---|
action |
JavaScript 1.0 |
Contains the URL to which the form will be submitted and corresponds the action attribute. |
elements |
JavaScript 1.0 |
Returns an array of the elements in the form. |
encoding |
JavaScript 1.0 |
Indicates the encoding type for the form and corresponds to the enctype attribute. |
length |
JavaScript 1.0 |
Indicates the number of elements in the form. |
method |
JavaScript 1.0 |
Indicates the HTTP method to be used to submit the form ("post" or "get") and corresponds to the method attribute. |
name |
JavaScript 1.0 |
Indicates the name of the form. Corresponds to the name attribute. |
target |
JavaScript 1.0 |
Indicates the window at which the contents will be targeted and corresponds to the target attribute. |
Method |
Introduced |
Description |
---|---|---|
reset() |
JavaScript 1.1 |
Resets the form to its default state. |
submit() |
JavaScript 1.0 |
Submits the form. |
JavaScript actually represents a frame using a window object. Every Frame object is a window object, and has all the methods and properties of a window object. However, a window that is a frame differs slightly from a top-level window. To create and reference a frame, we use the HTML <frameset> and <FRAME> elements and the frames property of the window object.
The Hidden object represents a hidden HTML input element, used to send information to the server, which you don't want to appear on the page (but note that this information is appended to the URL when submitted). Introduced in JavaScript 1.0, Jscript 1.0. The Hidden object is created with an HTML <input> tag with the type attribute set to "hidden" and referenced through the forms property of the document object.
Property |
Introduced |
Description |
---|---|---|
form |
JavaScript 1.0 |
References the form to which the Hidden object belongs. |
name |
JavaScript 1.0 |
Indicates the name of the Hidden object. Corresponds to the name attribute. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "hidden". |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
The history object is used to contain information about the URLs the user has previously visited. Introduced in JavaScript 1.0, Jscript 1.0. The history object cannot be created programmatically but can be referenced through the history property of the window object.
Property |
Introduced |
Description |
---|---|---|
length |
JavaScript 1.0 |
Indicates the number of entries in the history list. |
Method |
Introduced |
Description |
---|---|---|
back() |
JavaScript 1.0 |
Loads the previous URL in the history list. |
forward() |
JavaScript 1.0 |
Loads the next URL in the history list. |
go() |
JavaScript 1.0 |
Loads the specified URL from the history list. |
This object represents an image in the HTML page. Introduced in JavaScript 1.1, Jscript 3.0. The img object can be created with the Image constructor.
Alternatively, it can be created with an HTML <img> tag and referenced with the images property of the document object.
The img object supports the following event handlers:
onabort
onerror
onload
Property |
Introduced |
Description |
---|---|---|
border |
JavaScript 1.1 |
Indicates the width of the border around the image and corresponds to the border attribute. |
complete |
JavaScript 1.1 |
Indicates whether the browser has completed loading the image. |
height |
JavaScript 1.1 |
Indicates the height of the image and corresponds to the height attribute. |
hspace |
JavaScript 1.1 |
Indicates the size of the horizontal margin and corresponds to the hspace attribute. |
lowsrc |
JavaScript 1.1 |
Indicates the URL for a lower resolution image to load before the "real" image is displayed, and corresponds to the lowsrc attribute. |
name |
JavaScript 1.1 |
Indicates the name of the image. Corresponds to the name attribute. |
src |
JavaScript 1.1 |
Indicates the URL for the image and corresponds to the src attribute. |
vspace |
JavaScript 1.1 |
Indicates the size of the vertical margin and corresponds to the vspace attribute. |
width |
JavaScript 1.1 |
Indicates the width of the image and corresponds to the width attribute. |
This object represents a link to another page or to another part of the same page. Introduced in JavaScript 1.0, Jscript 1.0. Created through the link() method of the String object or through HTML <A> or <area> tags; in the latter case, it can be referenced through the links property of the document object.
Note that the Link object cannot be referenced through its name attribute, either in Navigator or in Internet Explorer.
The Link object supports the following events:
onclick
ondblclick
onkeydown
onkeypress
onkeyup
onmousedown
onmouseout
onmouseup
onmouseover
Property |
Introduced |
Description |
---|---|---|
hash |
JavaScript 1.0 |
Indicates the anchor part of the URL. |
host |
JavaScript 1.0 |
Indicates the hostname and port number of the URL. |
hostname |
JavaScript 1.0 |
Indicates the hostname from the URL. |
href |
JavaScript 1.0 |
Indicates the entire URL. |
pathname |
JavaScript 1.0 |
Indicates the path and file name of an object. |
port |
JavaScript 1.0 |
Indicates the port number in the URL. |
protocol |
JavaScript 1.0 |
Indicates the transport protocol to use (such as "http:" or "https:"), including the colon. |
search |
JavaScript 1.0 |
Indicates the query string appended to the URL. |
target |
JavaScript 1.0 |
Indicates the window at which the contents will be targeted and corresponds to the target attribute. |
The location object represents the web page currently being displayed in the browser. Introduced in JavaScript 1.0, Jscript 1.0. The location object cannot be created programmatically, but can be referenced through the location property of the window object.
Property |
Introduced |
Description |
---|---|---|
hash |
JavaScript 1.0 |
Indicates the anchor part of the URL. |
host |
JavaScript 1.0 |
Indicates the hostname and port number of the URL. |
hostname |
JavaScript 1.0 |
Indicates the hostname from the URL. |
href |
JavaScript 1.0 |
Indicates the entire URL. |
pathname |
JavaScript 1.0 |
Indicates the path and file name of an object. |
port |
JavaScript 1.0 |
Indicates the port number in the URL. |
protocol |
JavaScript 1.0 |
Indicates the transport protocol to use (such as "http:" or "https:"), including the colon. |
search |
JavaScript 1.0 |
Indicates the query string appended to the URL. |
Method |
Introduced |
Description |
---|---|---|
reload() |
JavaScript 1.1 |
Reloads the current document. |
replace() |
JavaScript 1.1 |
Loads the specified URL over the current history entry. |
This object represents the browser and contains information about the type and version of browser in use. Introduced in JavaScript 1.0, Jscript 1.0. This object cannot be created programmatically, but can be referenced through the navigator keyword.
Property |
Introduced |
Description |
---|---|---|
appCodeName |
JavaScript 1.0 |
Returns the code name of the browser. This is "Mozilla" for both Navigator and Internet Explorer. |
appName |
JavaScript 1.0 |
Returns the name of the browser. This is "Netscape" for Navigator and "Microsoft Internet Explorer" for IE. |
appVersion |
JavaScript 1.0 |
Returns information about the browser, including the version number and the platform on which it is running. |
mimeTypes |
JavaScript 1.1 |
Returns an array of the MIME types supported by the client. Included for compatibility only in IE, and returns an empty array. |
platform |
JavaScript 1.2 |
Returns a string indicating the operating system on which the browser is running (for example, "Win32"). |
plugins |
JavaScript 1.1 |
Returns an array of the plug-ins installed. Included for compatibility only in IE, and returns an empty array. |
System language |
IE 4 |
Specifies the default language of the operating system used by the Netscape-specific language property. |
userAgent |
JavaScript 1.0 |
Specifies the browser value for the user agent header in http requests. |
userLanguage |
IE 4 |
Specifies the preferred language using the standard codes in the Netscape Language property. |
Method |
Introduced |
Description |
---|---|---|
javaEnabled() |
JavaScript 1.1 |
Indicates whether Java is enabled. |
taintEnabled() |
JavaScript 1.1 (removed 1.2) |
Specifies whether data tainting is enabled. Data tainting is not supported by IE, so this always returns False. |
The Option object represents an option in an HTML <select> element. Introduced in JavaScript 1.0, Jscript 1.0. An Option object can be created in two ways: It is created by the <option> tag, or it can be created on the fly with the Option constructor.
Property |
Introduced |
Description |
---|---|---|
defaultSelected |
JavaScript 1.1 |
Indicates whether the option is selected by default when the page is loaded. |
index |
JavaScript 1.0 |
The zero-based index position of an option in the array of options for the selection list. |
selected |
JavaScript 1.0 |
Indicates whether the option is currently selected. |
text |
JavaScript 1.0 |
Indicates the text for the option. |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
This object represents a password input element. Introduced in JavaScript 1.0, Jscript 1.0. Created through an HTML <input> element with the type attribute set to "password" and referenced through the elements array of a Form object.
Note |
Passwords entered in this way are not secure; they are appended to the URL as a query. |
The Password object supports two events:
onblur
onfocus
Property |
Introduced |
Description |
---|---|---|
defaultValue |
JavaScript 1.1 |
Indicates the default value for the password. |
form |
JavaScript 1.0 |
References the form to which the Password object belongs. |
name |
JavaScript 1.0 |
Indicates the name of the Password object. Corresponds to the name attribute. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "password". |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
Method |
Introduced |
Description |
---|---|---|
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
Select() |
JavaScript 1.0 |
Selects the input area of the Password object. |
This object represents a radio button in a form. Introduced in JavaScript 1.0, Jscript 1.0. A number of radio buttons can be created with an array of HTML <input> elements with a type attribute set to "RADIO" and with the same name; assigning different names will cause the radio buttons to belong to different groups, so the user will be able to select any number. The array of radio buttons can be accessed through the elements array of a Form object; an individual button can then be accessed through an index of this array.
The Radio object supports the following events:
onblur
onclick
onfocus
Property |
Introduced |
Description |
---|---|---|
checked |
JavaScript 1.0 |
Indicates whether a specific radio button is currently checked. |
defaultChecked |
JavaScript 1.0 |
Indicates whether a specific radio button is checked by default. |
form |
JavaScript 1.0 |
References the form to which the Radio object belongs. |
name |
JavaScript 1.0 |
Indicates the name of the Radio object. Corresponds to the name attribute. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "radio." |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
Method |
Introduced |
Description |
---|---|---|
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
click() |
JavaScript 1.0 |
Simulates a mouse-click on the element and fires the onclick event. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
The Reset object represents a reset button in a form. Introduced in JavaScript 1.0, Jscript 1.0. A Reset object is created with an HTML <input> element with the type attribute set to "RESET" and referenced through the elements array of a Form object.
The Reset object supports the following events:
onblur
onclick
onfocus
Property |
Introduced |
Description |
---|---|---|
form |
JavaScript 1.0 |
References the form to which the Reset object belongs. |
name |
JavaScript 1.0 |
Indicates the name of the reset button. Corresponds to the name attribute. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "reset." |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
Method |
Introduced |
Description |
---|---|---|
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
click() |
JavaScript 1.0 |
Simulates a mouse-click on the element and fires the onclick event. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
This object represents the client's screen and contains information about the display capabilities of the client. Introduced in JavaScript 1.2, Jscript 3.0. The screen object is created automatically and can be referenced through the screen keyword.
Property |
Introduced |
Description |
---|---|---|
availHeight |
JavaScript 1.2 |
Indicates the vertical range of the screen potentially available to the browser (in pixels). |
availWidth |
JavaScript 1.0 |
Indicates the horizontal range of the screen potentially available to the browser (in pixels). |
colorDepth |
JavaScript 1.0 |
Indicates the number of bits used for colors on the client's screen. |
height |
JavaScript 1.0 |
Indicates the vertical range of the screen (in pixels). |
width |
JavaScript 1.0 |
Indicates the horizontal range of the screen (in pixels). |
This object represents a selection list in a form. Introduced in JavaScript 1.0, Jscript 1.0. Created with an HTML <select> element and referenced through the elements array of a Form object.
The Select object supports the following events:
Property |
Introduced |
Description |
---|---|---|
form |
JavaScript 1.0 |
References the form to which the Select object belongs. |
length |
JavaScript 1.0 |
Returns the number of options in the selection list. |
name |
JavaScript 1.0 |
Indicates the name of the Select object. Corresponds to the name attribute. |
options |
JavaScript 1.0 |
Returns an array of the Option objects in the selection list. |
selectedIndex |
JavaScript 1.0 |
Returns the index of the first selected option. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "select-multiple" for a multiple selection list or "select-one" if only one item in the list may be selected. |
Method |
Introduced |
Description |
---|---|---|
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
The Submit object represents a submit button in a form. Introduced in JavaScript 1.0, Jscript 1.0. Created with an HTML <input> element with the type attribute set to "SUBMIT" and referenced through the elements array of the Form object.
The Submit object supports the following events:
onblur
onclick
onfocus
Property |
Introduced |
Description |
---|---|---|
form |
JavaScript 1.0 |
References the form to which the Submit object belongs. |
name |
JavaScript 1.0 |
Indicates the name of the submit button. Corresponds to the name attribute. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "submit." |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
Method |
Introduced |
Description |
---|---|---|
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
click() |
JavaScript 1.0 |
Simulates a mouse-click on the element and fires the onclick event. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
This object represents a text box. Introduced in JavaScript 1.0, Jscript 1.0. Created with an HTML <input> element with the type attribute set to "text" and referenced through the elements array of the Form object.
Text objects support the following events:
onblur
onchange
onfocus
onselect
Property |
Introduced |
Description |
---|---|---|
defaultValue |
JavaScript 1.0 |
Indicates the default value for the text box. |
form |
JavaScript 1.0 |
References the form to which the Text object belongs. |
name |
JavaScript 1.0 |
Indicates the name of the text box. Corresponds to the name attribute. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "text". |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
Method |
Introduced |
Description |
---|---|---|
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
select() |
JavaScript 1.0 |
Selects the input area of the Text object. |
This object represents a textarea in a form. Introduced in JavaScript 1.0, Jscript 1.0. Created with an HTML <TEXTAREA> element and referenced with the elements array of the Form object.
The Textarea object supports seven events:
onblur
onchange
onfocus
onkeydown
onkeypress
onkeyup
onselect
Property |
Introduced |
Description |
---|---|---|
defaultValue |
JavaScript 1.0 |
Indicates the default value for the textarea. |
form |
JavaScript 1.0 |
References the form to which the Textarea object belongs. |
name |
JavaScript 1.0 |
Indicates the name of the textarea. Corresponds to the name attribute. |
type |
JavaScript 1.1 |
Indicates the type of element, corresponding to the type attribute. This will return "textarea". |
value |
JavaScript 1.0 |
Indicates the value of the element, corresponding to the value attribute. |
Method |
Introduced |
Description |
---|---|---|
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
focus() |
JavaScript 1.0 |
Causes the element to receive focus. |
select() |
JavaScript 1.0 |
Selects the input area of the Textarea object. |
This object represents a window or frame in the browser. Introduced in JavaScript 1.0, Jscript 1.0. A window object is automatically created for every browser window open, and can be referenced with the window keyword. However, we can call the methods and properties of the window object without explicitly naming the object.
The window object supports six events:
Property |
Introduced |
Description |
---|---|---|
closed |
JavaScript 1.1 |
Indicates whether a window is closed. |
defaultStatus |
JavaScript 1.0 |
Indicates the default text displayed in the window's status bar. |
document |
JavaScript 1.0 |
Returns a reference to the document object in the current window. |
frames |
JavaScript 1.0 |
Returns an array of the frames in the window. |
history |
JavaScript 1.1 |
Returns a reference to the history object for the window. |
length |
JavaScript 1.0 |
Returns the number of frames in the window. |
location |
JavaScript 1.0 |
Returns the location object for the current window. |
name |
JavaScript 1.0 |
Indicates the name of the window. Corresponds to the name attribute. |
offscreenBuffering |
JavaScript 1.2 |
Specifies whether off-screen buffering is to be used to update objects in the window before they are made visible. |
opener |
JavaScript 1.1 |
Returns a reference to the window that called the current window. |
parent |
JavaScript 1.0 |
Returns a reference to the window or frame to which the current frame belongs. |
self |
JavaScript 1.0 |
Returns a reference to the current window. |
status |
JavaScript 1.0 |
Indicates the current message in the status bar. |
top |
JavaScript 1.0 |
Returns a reference to the topmost window. |
Method |
Introduced |
Description |
---|---|---|
alert() |
JavaScript 1.0 |
Displays a dialog box containing a message and an OK button. |
blur() |
JavaScript 1.0 |
Causes the element to lose focus. |
clearInterval() |
JavaScript 1.2 |
Cancels an interval set with the setInterval method. |
clearTimeout() |
JavaScript 1.0 |
Cancels a timeout set with the setTimeout method. |
close() |
JavaScript 1.0 |
Closes the window. |
confirm() |
JavaScript 1.0 |
Displays a dialog box containing a message and OK and Cancel buttons. |
focus() |
JavaScript 1.1 |
Causes the element to receive focus. |
moveBy() |
JavaScript 1.2 |
Moves the window by the specified number of pixels on the x- and y-axes. |
moveTo() |
JavaScript 1.2 |
Moves the top-left corner of the window to the specified position on the x- and y-axes. |
open() |
JavaScript 1.0 |
Opens a new window. |
print() |
JavaScript 1.2 |
Prints the contents of the window or frame. |
prompt() |
JavaScript 1.0 |
Displays a dialog box with a message, an input area, and OK and Cancel buttons. |
resizeBy() |
JavaScript 1.2 |
Resizes the window by the specified x- and y-offsets by adjusting the position of the bottom-right corner. |
resizeTo() |
JavaScript 1.2 |
Resizes the window to the specified dimensions by adjusting the position of the bottom-right corner. |
scroll() |
JavaScript 1.1 |
Scrolls the window to the specified coordinates. |
scrollBy() |
JavaScript 1.2 |
Scrolls the window by the specified x- and y- offsets. |
scrollTo() |
JavaScript 1.2 |
Scrolls the window to the specified coordinates, such that the specified point becomes the top-left corner. |
setInterval() |
JavaScript 1.2 |
Evaluates the given expression every time the specified number of milliseconds elapses. |
setTimeout() |
JavaScript 1.0 |
Evaluates the given expression (once only) after the specified number of milliseconds has elapsed. |