The anchors collection

JS Reference
JS Overview
JS Array
JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The anchors Collection

Definition and Usage

The anchors collection returns a reference to all Anchor objects in the document.

Syntax

document.anchors[]

Example

<html>
<body>
<a name="first">First anchor</a><br />
<a name="second">Second anchor</a><br />
<a name="third">Third anchor</a><br />
<br />
Number of anchors in this document:
<script type="text/javascript">
document.write(document.anchors.length)
</script>
</body>
</html>


The forms collection

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The forms Collection

Definition and Usage

The forms collection returns a reference to all Form objects in the document.

Syntax

document.forms[]

Example

<html>
<body>
<form name="Form1"></form>
<form name="Form2"></form>
<form name="Form3"></form>
<script type="text/javascript">
document.write("This document contains: ")
document.write(document.forms.length + " forms.")
</script>
</body>
</html>


The images collection

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The images Collection

Definition and Usage

The images collection returns a reference to all Image objects in the document.

Syntax

document.images[]

Example

<html>
<body>
<img border="0" src="hackanm.gif" width="48" height="48">
<br />
<img border="0" src="compman.gif" width="107" height="98">
<br /><br />

<script type="text/javascript">
document.write("This document contains: ")
document.write(document.images.length + " images.")
</script>
</body>
</html>


HTML DOM Tutorial

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Tutorial

HTML DOM Tutorial

The HTML Document Object Model (HTML DOM) defines a standard way for accessing and manipulating HTML documents.

The DOM presents an HTML document as a tree structure, and gives access to the structure through a set of objects.

Start learning the HTML DOM!

Table Of Contents

Introduction to HTML DOM
This chapter is an introduction to HTML DOM, what it is, and how it can be used.

HTML DOM Example
This chapter describes an HTML DOM example.

HTML DOM Reference
This chapter contains a complete reference to all the HTML DOM objects.


HTML DOM Example

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Example

The HTML DOM defines an HTML document as a collection of objects.

Objects have properties and methods. Objects can respond to events.

An HTML DOM Example

This coding example shows how the background color of an HTML document can be changed to yellow when a user clicks on it:

<html>

<head>
<script type="text/javascript">
function ChangeColor()
{
document.body.bgColor="yellow"
}
</script>
</head>

<body onclick="ChangeColor()">
Click on this document!
</body>

</html>

Document Objects

The HTML DOM defines HTML documents as a collection of objects.

The document object is the parent of all the other objects in an HTML document.

The document.body object represents the <body> element of the HTML document.

The document object is the parent of the body object, and the body object is a child of the document object.

Object Properties

HTML document objects can have properties (also called attributes).

The document.body.bgColor property defines the background color of the body object.

The statement document.body.bgColor="yellow" in the example above, sets the background color of the HTML document to yellow.

Object Events

HTML document objects can respond to events.

The onclick="ChangeColor()" attribute of the <body> element in the example above, defines an action to take place when the user clicks on the document.

Functions

The ChangeColor() function in the example above, is a JavaScript function.

The function will be triggered (started) when a user clicks on the HTML document.

Changing Style

The HTML DOM also defines a model for changing the styles of HTML objects.

The coding example below shows how to obtain the same effect as the first example, by changing the style of the body object:

<html>

<head>
<script type="text/javascript">
function ChangeColor()
{
document.body.style.background="yellow"
}
</script>
</head>

<body onclick="ChangeColor()">
Click on this document!
</body>

</html>


HTML DOM Introduction

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Introduction

The HTML Document Object Model (HTML DOM) defines a standard way for accessing and manipulating HTML documents.

What is the DOM?

"The W3C Document Object Model (DOM) is a platform and language neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."

The W3C DOM provides a standard set of objects for representing HTML and XML documents, and a standard interface for accessing and manipulating them.

The DOM is separated into different parts (Core, XML, and HTML) and different levels (DOM Level 1/2/3):

  • Core DOM - defines a standard set of objects for any structured document
  • XML DOM - defines a standard set of objects for XML documents
  • HTML DOM - defines a standard set of objects for HTML documents

What is the HTML DOM?

  • The HTML DOM is the Document Object Model for HTML
  • The HTML DOM is platform and language independent
  • The HTML DOM defines a standard set of objects for HTML, and a standard way to access and manipulate HTML documents
  • The HTML DOM is a W3C standard

The HTML DOM views HTML documents as a tree structure of elements embedded within other elements. All elements, their containing text and their attributes, can be accessed through the DOM tree. Their contents can be modified or deleted, and new elements can be created by the DOM. The elements, their text, and their attributes are all known as nodes.

We Will Use JavaScript

The HTML DOM is platform and language independent. It can be used by any programming language like Java, JavaScript, and VBScript.

In this tutorial we will use JavaScript.

An HTML DOM Example

This coding example shows how the background color of an HTML document can be changed to yellow when a user clicks on it:

<html>

<head>
<script type="text/javascript">
function ChangeColor()
{
document.body.bgColor="yellow"
}
</script>
</head>

<body onclick="ChangeColor()">
Click on this document!
</body>

</html>


HTML DOM Anchor Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Anchor Object

Anchor Object

The Anchor object represents an HTML hyperlink. For each instance of an HTML <a> tag in a document, an Anchor object is created.

An anchor can be used to create a link to another document (with the href attribute) or to create a bookmark inside a document (with the name attribute).

You can access an Anchor object by indexing the anchors' array (by number or name) of the Document object or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Anchor Object Properties

Property | Description | IE | F | N | W3C
accessKey | Sets or returns the keyboard key to access the link | 5 | 1 | 6 | Yes
charset | Sets or returns the character set of the linked resource | 6 | 1 | 6 | Yes
coords | Sets or retrieves a comma-separated list with coordinates, defining an active region geometry | 6 | 1 | 6 | Yes
href | Sets or returns the URL of the linked resource | 5 | 1 | 6 | Yes
hreflang | Sets or returns the language code of the linked resource | 6 | 1 | 6 | Yes
id | Sets or returns the id of the link | 4 | 1 |  | No
innerHTML | Sets or returns the text of the link | 4 | 1 |  | Yes
name | Sets or returns the name of the link | 4 | 1 | 4 | Yes
rel | Sets or returns the relationship between the current document and the target URL | 5 | 1 | 6 | Yes
rev | Sets or returns the relationship between the current document and the target URL | 5 | 1 | 6 | Yes
shape | Sets or returns the active area. Coordinates are given by coords | 6 | 1 | 6 | Yes
tabIndex | Sets or returns the index that defines the tab order for the link | 5 | 1 | 6 | Yes
target | Sets or returns where to open the target URL | 5 | 1 | 6 | Yes
type | Sets or returns the MIME type of the linked resource | 6 | 1 | 6 | Yes

Anchor Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the link | 5 | 1 | 6 | Yes
focus() | Gives focus to the link | 5 | 1 | 6 | Yes

Anchor Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the link loses focus | 3 | 1 | 2 |
onFocus | Executes some code when the link gets focus | 3 | 1 | 2 |


HTML DOM Applet Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Applet Object

Applet Object

The Applet object represents an HTML applet element. The applet element is used to place executable content on a page.

Applet is deprecated in favor of Object!


HTML DOM Area Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Area Object

Area Object

The Area object represents an area of an image-map (An image-map is an image with clickable areas). For each instance of an HTML <area> tag in a document, an Area object is created.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Area Object Properties

Property | Description | IE | F | N | W3C
accessKey | Sets or returns the keyboard key to access the area object | 4 |  |  | Yes
alt | Sets or returns an alternate text for browsers that cannot show an area | 5 | 1 | 6 | Yes
coords | Sets or returns a comma-separated list of lengths that defines the clickable area | 5 | 1 | 6 | Yes
hash | Sets or returns the anchor part of the URL (begins with a #) | 4 | 1 | 3 | No
host | Sets or returns the hostname and port of the URL | 4 | 1 | 3 | No
hostname | Sets or returns the server name and domain name/IP address of the URL | 4 | 1 | 3 | No
href | Sets or returns the entire URL | 4 | 1 | 3 | Yes
id | Sets or returns the id of the area object (In IE 4 this property is read-only) | 4 | 1 |  | No
noHref | Sets or returns if the area should be inactive | 5 | 1 | 6 | Yes
pathname | Sets or returns the pathname of the URL | 4 | 1 | 3 | No
port | Sets or returns the URL port the server uses | 4 | 1 | 3 | No
protocol | Sets or returns the URL protocol (including the first colon) e.g "http:", "https:" | 4 | 1 | 3 | No
search | Sets or returns the URL query string section (including the question mark (?)) | 4 | 1 | 3 | No
shape | Sets or returns the shape of the area | 5 | 1 | 6 | Yes
tabIndex | Sets or returns the tab order of the area object | 5 |  |  | Yes
target | Sets or returns URL link's target name | 4 | 1 | 3 | Yes

Area Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onClick | Executes some code when a Click event occurs | 4 | 1 | 3 |
onDblClick | Executes some code when a Doubleclick event occurs | 4 | 1 | 3 |
onMouseOut | Executes some code when a Mouseout event occurs | 4 | 1 | 3 |
onMouseOver | Executes some code when a Mouseover event occurs | 4 | 1 | 3 |


HTML DOM Base Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Base Object

Base Object

The Base object represents an HTML base element. For each instance of an HTML <base> tag in a document, a Base object is created.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Base Object Properties

Property | Description | IE | F | N | W3C
href | Sets or returns the base URL for the document | 5 | 1 | 6 | Yes
id | Sets or returns the id of the base object | 4 | 1 |  | No
target | Sets or returns the default target frame or window | 5 | 1 | 6 | Yes


HTML DOM BaseFont Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM BaseFont Object

BaseFont Object

The BaseFont object represents an HTML basefont element. The basefont element is used to define a default font (font size, color, and font type) for a document.

BaseFont is deprecated in favor of Style!


HTML DOM Body Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Body Object

Body Object

The Body object represents the body of the document (the HTML body).

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Body Object Properties

Property | Description | IE | F | N | W3C
accessKey | Sets or returns the keyboard key to access the body object | 5 | - |  | No
aLink | Sets or returns the color of active links in the document | 5 | 1 | 6 | Yes
background | Sets or returns the URL of the background image of the document | 5 | 1 | 6 | Yes
bgColor | Sets or returns the background color of the document | 5 | 1 | 6 | Yes
id | Sets or returns the id of the body (In IE 4 this property is read-only) | 4 | 1 |  | No
link | Sets or returns the color of links in the document | 5 | 1 | 6 | Yes
scrollLeft | Sets or returns the distance between the left edge of the body and the leftmost portion of the content visible in the window | 5 | 1 | 7 | No
scrollTop | Sets or returns the distance between the top edge of the body and the topmost portion of the content visible in the window | 5 | 1 | 7 | No
text | Sets or returns the color of text in the document | 5 | 1 | 6 | Yes
vLink | Sets or returns the color of visited links in the document | 5 | 1 | 6 | Yes


HTML DOM Button Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Button Object

Button Object

The Button object represents a button in an HTML form. For each instance of an <input type="button"> tag in an HTML form, a Button object is created.

You can access a Button object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Button Object Properties

Property | Description | IE | F | N | W3C
accessKey | Sets or returns the keyboard key to access the button | 5 |  |  | Yes
disabled | Sets or returns whether or not the button should be disabled | 5 | 1 |  | Yes
form | Returns a reference to the form that contains the button | 3 | 1 | 2 | Yes
id | Sets or returns the id of the button | 4 | 1 |  | No
name | Sets or returns the name of the button | 3 | 1 | 2 | Yes
tabIndex | Sets or returns the index that defines the tab order for the button | 5 |  |  | Yes
type | Returns the type of the form element. For a Button object it will be "button" | 4 | 1 | 3 | Yes
value | Sets or returns the text that is displayed on the button | 3 | 1 | 2 | Yes

Button Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the button | 3 | 1 | 2 |
click() | Simulates a mouse-click on the button | 3 | 1 | 2 |
focus() | Gives focus to the button | 3 | 1 | 2 |

Button Objects Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the button loses focus | 3 | 1 | 2 |
onClick | Executes some code when the button is clicked | 3 | 1 | 2 |
onFocus | Executes some code when the button gets focus | 3 | 1 | 2 |
onMouseDown | Executes some code when a mouse button is pressed | 4 | 1 | 4 |
onMouseUp | Executes some code when a mouse button is released | 4 | 1 | 4 |


HTML DOM Checkbox Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Checkbox Object

Checkbox Object

The Checkbox object represents a checkbox in an HTML form. For each instance of an <input type="checkbox"> tag in an HTML form, a Checkbox object is created.

You can access a Checkbox object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Checkbox Object Properties

Property | Description | IE | F | N | W3C
accept | Sets or returns a list of content types, which the server processing this form will handle correctly | - |  |  | Yes
accessKey | Sets or returns the keyboard key to access the checkbox | 4 |  |  | Yes
align | Sets or returns the alignment of the checkbox according to the surrounding text | - |  |  | Yes
alt | Sets or returns an alternate text to display if the browser does not support checkboxes | - |  |  | Yes
checked | Sets or returns whether or not the checkbox is checked | 3 | 1 | 2 | Yes
defaultChecked | Sets or returns the default value of the checked attribute (true if checked by default and false if not) | 3 | 1 | 2 | Yes
disabled | Sets or returns whether or not the checkbox should be disabled | 3 | 1 |  | Yes
form | Returns a reference to the form that contains the checkbox | 3 | 1 | 2 | Yes
id | Sets or returns the id of the checkbox (In IE 4 this property is read-only) | 4 | 1 |  | No
name | Sets or returns the name of the checkbox | 3 | 1 | 2 | Yes
tabIndex | Sets or returns the index that defines the tab order for the checkbox | 4 |  |  | Yes
type | Returns the type of the form element. For a checkbox it will be "checkbox" | 4 | 1 | 3 | Yes
value | Sets or returns the value of the value attribute of the checkbox | 3 | 1 | 2 | Yes

Checkbox Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the checkbox | 3 | 1 | 2 | Yes
click() | Simulates a mouse-click in the checkbox | 3 | 1 | 2 | Yes
focus() | Gives focus to the checkbox | 3 | 1 | 2 | Yes

Checkbox Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the checkbox loses focus | 3 | 1 | 2 |
onClick | Executes some code when the checkbox is clicked | 3 | 1 | 2 |
onFocus | Executes some code when the checkbox gets focus | 3 | 1 | 2 |
onMouseDown | Executes some code when a mouse button is pressed | 4 | 1 | 4 |
onMouseUp | Executes some code when a mouse button is released | 4 | 1 | 4 |


HTML DOM Document Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Document Object

Document Object

The Document object is an object that can be used to access all elements in a page.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard), D: Deprecated.

Document Object Collections

Collection | Description | IE | F | N | W3C
anchors[] | Returns a reference to all Anchor objects in the document | 3 | 1 | 2 | Yes
applets[] | Returns a reference to all Applet objects in the document | 4 | 1 | 3 | Yes
attributes[] |  | - | 1 | 6 | No
childNodes[] |  | 5 | 1 | 6 | No
embeds[] | Returns a reference to all embedded objects in the document | 4 | 1 | 3 | No
forms[] | Returns a reference to all Form objects in the document | 3 | 1 | 2 | Yes
images[] | Returns a reference to all Image objects in the document | 4 | 1 | 3 | Yes
links[] | Returns a reference to all Link objects in the document | 3 | 1 | 2 | Yes
plugins[] |  | - | 1 | 6 | No
stylesheets[] |  | 5 | 1 | 6 | No

Document Object Properties

Property | Description | IE | F | N | W3C
alinkColor | Sets or returns the color of the active links in the document | 3 | 1 | 2 | D
bgColor | Sets or returns the background-color of the document | 3 | 1 | 2 | D
body | Specifies the beginning and end of the document body | 5 | 1 | 6 | Yes
cookie | Sets or returns all cookies associated with the document | 3 | 1 | 2 | Yes
documentElement | Returns a reference to the root node of the document | 5 | 1 | 6 | No
domain | Returns the document server's domain name | 4 | 1 | 3 | Yes
fgColor | Sets or returns the text-color of the document | 3 | 1 | 2 | D
lastModified | Returns the date and time the document was last modified | 3 | 1 | 2 | No
linkColor | Sets or returns the color of the links in the document | 3 | 1 | 2 | D
referrer | Returns the URL of the document that loaded the current document | 3 | 1 | 2 | Yes
title | Returns the title of the document | 3 | 1 | 2 | Yes
URL | Returns the URL of the current document | 4 | 1 | 3 | Yes
vlinkColor | Sets or returns the color of the visited links in the document | 3 | 1 | 2 | D

Document Object Methods

Method | Description | IE | F | N | W3C
clear() | Clears all elements in the document | - | 1 | 2 | No
close() | Closes the output stream and displays the sent data | 3 | 1 | 2 | Yes
createAttribute("name") | Creates an attribute with a specified name | 6 | 1 | 6 | No
createElement("tag") | Creates an element | 5 | 1 | 6 | Yes
createTextNode("txt") | Creates a text string | 5 | 1 | 6 | Yes
focus() | Gives the document focus | 5 | 1 | 6 | No
getElementById() | Returns a reference to the first object with the specified ID | 5 | 1 | 6 | Yes
getElementsByName() | Returns a collection of objects with the specified NAME | 5 | 1 | 6 | Yes
getElementsByTagName("tag") | Returns a collection of objects with the specified TAGNAME | 5 | 1 | 6 | No
open() | Opens a document for writing | 3 | 1 | 2 | Yes
write() | Writes a text string to a document | 3 | 1 | 2 | Yes
writeln("str") | Writes a text string followed by a new line character to a document opened by open() | 3 | 1 | 2 | Yes

Document Object Events

Syntax: document.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onClick | Executes some code when a Click event occurs | 5 | 1 | 6 |
onDblClick | Executes some code when a Doubleclick event occurs | 5 | 1 | 6 |
onFocus | Executes some code when a Focus event occurs | 5 | 1 | 6 |
onKeyDown | Executes some code when a Keydown event occurs | 5 | 1 | 6 |
onKeyPress | Executes some code when a Keypress event occurs | 5 | 1 | 6 |
onKeyUp | Executes some code when a Keyup event occurs | 5 | 1 | 6 |
onMouseDown | Executes some code when a Mousedown event occurs | 5 | 1 | 6 |
onMouseMove | Executes some code when a Mousemove event occurs | 5 | 1 | 6 |
onMouseOut | Executes some code when a Mouseout event occurs | 5 | 1 | 6 |
onMouseOver | Executes some code when a Mouseover event occurs | 5 | 1 | 6 |
onMouseUp | Executes some code when a Mouseup event occurs | 5 | 1 | 6 |
onResize | Executes some code when a Resize event occurs | 5 | 1 | 6 |


HTML DOM Event Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Event Object

Event Object

The Event object represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons.

The event object is available only during an event - that is, you can use it in event handlers but not in other code.

In VBScript, you must access the event object through the window object.

The Event object's collections, properties and events are described below:

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Collections

Collection | Description | IE | F | N | W3C
bookmarks[] | Returns a collection of bookmarks connected to the rows effected by the events |  |  |  |
boundElements[] | Returns a collection of all elements on a page which are bound to a data test |  |  |  |

Properties

Property | Description | IE | F | N | W3C
Abstract | Returns the Abstract content in an Advanced Stream Redirector (ASX) file | 6
altKey | Sets or returns a Boolean value that indicates the state of the ALT key | 4
altLeft | Returns a Boolean value that indicates the state of the left ALT key | 5
banner | Returns the Banner content in an ASX file | 6
button Sets or returns the mouse button pressed by the user
  • 0 - Default. No button pressed
  • 1 - Left button pressed
  • 2 - Right button pressed
  • 3 - Left and right buttons pressed
  • 4 - Middle button pressed
  • 5 - Left and middle buttons pressed
  • 6 - Right and middle buttons pressed
  • 7 - All three buttons are pressed
 4
cancelBubble | Sets or returns a Boolean value that indicates whether or not the current event should bubble up the hierarchy of event handlers | 4
clientX | Sets or returns the x-coordinate of the mouse pointer - relative to the screen, excluding decorations and scroll bars | 4
clientY | Sets or returns the y-coordinate of the mouse pointer - relative to the screen, excluding decorations and scroll bars | 4
contentOverflow | 5
ctrlKey | Sets or returns a Boolean value that indicates the state of the CTRL key | 4
ctrlLeft | Sets or returns a Boolean value that indicates the state of the left CTRL key | 5
dataFld | Sets or returns the data column affected by the oncellchange event | 5
fromElement | Sets or returns the object from which activation or the mouse pointer is exiting during the event | 4
keyCode | Sets or returns the UNICODE of the key pressed | 4
MoreInfo | Returns the MoreInfo content in an ASX file | 6
nextPage | Returns the position of the next page within a print template | 5
offsetX | Sets or returns the x-coordinate of the mouse pointer relative to the object firing the event | 4
offsetY | Sets or returns the y-coordinate of the mouse pointer relative to the object firing the event | 4
propertyName | Sets or returns the name of the property that has changed on the object | 5
qualifier | 5
reason Sets or returns the result of a data transfer for a data source
  • 0 - Successfully
  • 1 - Aborted
  • 2 - Error
 4
recordset | Sets or returns a reference to the default record set in a data source | 4
repeat | Returns a Boolean value that indicates whether the ONKEYDOWN event is being repeated | 5
returnValue | Sets or returns the return value from an event | 4
saveType | Returns the clipboard type when ONCONTENTSAVE fires | 5
screenX | Sets or returns the x-coordinate of the mouse pointer - relative to the screen | 4
screenY | Sets or returns the y-coordinate of the mouse pointer - relative to the screen | 4
shiftKey | Returns a Boolean value that indicates the state of the SHIFT key | 4
shiftLeft | Returns a Boolean value that indicates the state of the left SHIFT key | 5
srcElement | Sets or returns the object that fired the event | 4
srcFilter | Sets or returns the filter object that fired the ONFILTERCHANGE event | 4
srcUrn | Sets or returns the Universal Resource Name (URN) of the behavior that fired the event | 5
toElement | Sets or returns a reference to the object toward which the user is moving the mouse pointer | 4
type | Sets or returns the event name | 4
userName | 5
wheelDelta | Returns the distance and the direction the wheel button has rolled | 5
x | Sets or returns the x-coordinate (in px) of the mouse pointer - relative to a relatively positioned parent element | 4
y | Sets or returns the y-coordinate (in px) of the mouse pointer - relative to a relatively positioned parent element | 4


HTML DOM FileUpload Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM FileUpload Object

FileUpload Object

For each instance of an <input type="file"> tag in an HTML form, a FileUpload object is created.

You can access a FileUpload object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

FileUpload Object Properties

Property | Description | IE | F | N | W3C
accept | Sets or returns a list of content types, which the server processing this form will handle correctly | - |  |  | Yes
accessKey | Sets or returns the keyboard key to access the FileUpload object | 4 |  |  | Yes
align | Sets or returns the alignment of the FileUpload object according to the surrounding text | - |  |  | Yes
alt | Sets or returns an alternate text to display if the browser does not support <input type="file"> | - |  |  | Yes
defaultValue | Sets or returns the initial value of the FileUpload object | 4 | 1 | 3 | Yes
disabled | Sets or returns whether or not the FileUpload object should be disabled | 4 |  |  | Yes
form | Returns a reference to the form that contains the FileUpload object | 4 | 1 | 3 | Yes
id | Sets or returns the id of the FileUpload object (In IE 4 this property is read-only) | 4 | 1 |  | No
name | Sets or returns the name of the FileUpload object | 4 | 1 | 3 | Yes
tabIndex | Sets or returns the index that defines the tab order for the FileUpload object | 4 |  |  | Yes
type | Returns the type of the form element. For a FileUpload object it will be "file" | 4 | 1 | 3 | Yes
value | Returns the file name of the FileUpload object after the text is set by user input | 4 | 1 | 3 | Yes

FileUpload Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the FileUpload object | 4 | 1 | 3 | Yes
click() | Simulates a mouse-click on the FileUpload object | 4 |  |  | No
focus() | Gives focus to the FileUpload object | 4 | 1 | 3 | Yes
select() | Selects the FileUpload object | 4 |  |  | Yes

FileUpload Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the FileUpload object loses focus | 4 | 1 | 3 |
onClick | Executes some code when the FileUpload object gets a mouse click | 4 | 1 | 3 |
onFocus | Executes some code when the FileUpload object gets focus | 4 | 1 | 3 |
onSelectStart | Executes some code when the FileUpload object gets selected | 4 |  |  |


HTML DOM Form Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Form Object

Form Object

The Form object represents an HTML form. For each instance of an HTML <form> tag in a document, a Form object is created.

Forms are used to prompt users for input. The input data is normally posted to a server for processing.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Form Object Collections

Collection | Description | IE | F | N | W3C
elements[] | Returns an array containing each element in the form | 3 | 1 | 2 | Yes

Form Object Properties

Property | Description | IE | F | N | W3C
acceptCharset | Sets or returns a list of character encodings for form data that must be accepted by the server processing the form | 3 |  |  | Yes
action | Sets or returns the URL of where the input data will be submitted | 3 | 1 | 2 | Yes
encoding | Sets or returns the MIME encoding for the form | 3 | 1 | 2 | No
enctype | Sets or returns the MIME encoding for the form | 5 | 1 | 6 | Yes
id | Sets or returns the id of the form (In IE 4 this property is read-only) | 4 | 1 |  | No
length | Returns the number of elements in a form | 3 | 1 | 2 | Yes
method | Sets or returns how form data is submitted to the server ("get" or "post") | 3 | 1 | 2 | Yes
name | Sets or returns the name of the form | 3 | 1 | 2 | Yes
tabIndex | Sets or returns the index that defines the tab order for the form | 5 |  |  | No
target | Sets or returns the target window or frame that responses are sent to after submission of a form | 3 | 1 | 2 | Yes

Form Object Methods

Method | Description | IE | F | N | W3C
reset() | Resets the default values of all elements in the form (same as clicking the Reset button) | 4 | 1 | 3 | Yes
submit() | Submits the form (same as clicking the Submit button) | 3 | 1 | 2 | Yes

Form Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onReset | Executes some code when a Reset event occurs | 4 | 1 | 3 |
onSubmit | Executes some code when a Submit event occurs | 3 | 1 | 2 |


HTML DOM Frame Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Frame Object

Frame Object

The Frame object represents an HTML frame. For each instance of an HTML <frame> tag in a document, a Frame object is created.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Frame Object Properties

Property | Description | IE | F | N | W3C
contentDocument | Returns the document the frame contains | - |  |  | Yes
frameBorder | Sets or returns whether to display a border for the frame | 5 | 1 | 6 | Yes
id | Sets or returns the id of the frame (In IE 4 this property is read-only) | 4 | 1 |  | No
longDesc | Sets or returns a URL to a long description of the frame | 6 |  |  | Yes
marginHeight | Sets or returns the top and bottom margins of the frame | 5 | 1 | 6 | Yes
marginWidth | Sets or returns the left and right margins of the frame | 5 | 1 | 6 | Yes
name | Sets or returns the name of the frame | 5 | 1 | 6 | Yes
noResize | Sets or returns whether the frame can be resized | 5 | 1 | 6 | Yes
scrolling | Sets or returns whether the frame can be scrolled | 5 | 1 | 6 | Yes
src | Sets or returns the URL to be loaded by the frame | 5 | 1 | 6 | Yes

Frame Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the frame | 5 | 1 |  | No
focus() | Gives focus to the frame | 5 | 1 |  | No

Frame Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the frame loses focus | 5 |  |  | No
onFocus | Executes some code when the frame gets focus | 5 |  |  | No


HTML DOM Frameset Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Frameset Object

Frameset Object

The Frameset object represents an HTML frameset.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Frameset Object Properties

Property | Description | IE | F | N | W3C
cols | Sets or returns the number of columns in the frameset | 5 | 1 | 6 | Yes
id | Sets or returns the id of the frameset (In IE 4 this property is read-only) | 4 | 1 |  | No
rows | Sets or returns the number of rows in the frameset | 5 | 1 | 6 | Yes

Frameset Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the frameset | 5 | 1 |  | No
focus() | Gives focus to the frameset | 5 | 1 |  | No

Frameset Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the frameset loses focus | 5 |  |  | No
onFocus | Executes some code when the frameset gets focus | 5 |  |  | No


HTML DOM Hidden Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Hidden Object

Hidden Object

The Hidden object represents a hidden field in an HTML form. For each instance of an <input type="hidden"> tag in an HTML form, a Hidden object is created.

You can access a Hidden object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Hidden Object Properties

Property | Description | IE | F | N | W3C
defaultValue | Sets or returns the initial value of the hidden field | 3 | 1 | 2 | Yes
form | Returns a reference to the hidden field's parent form | 3 | 1 | 2 | Yes
id | Sets or returns the id of the hidden field (In IE 4 this property is read-only) | 4 | 1 |  | No
name | Sets or returns the name of the hidden field | 3 | 1 | 2 | Yes
type | Returns the type of the form element. For a hidden object it will always be "hidden" | 4 | 1 | 3 | Yes
value | Sets or returns the value of the value attribute of the hidden field | 3 | 1 | 2 | Yes


HTML DOM History Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM History Object

History Object

The History object is an object that can be accessed through the history property of the Window object.

The History object consists of an array of URLs. These URLs are the URLs the user has visited within a browser window.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

History Object Properties

Property | Description | IE | F | N | W3C
length | Returns the number of elements in the history list | 3 | 1 | 2 |

History Object Methods

Method | Description | IE | F | N | W3C
back() | Loads the previous URL in the history list (same as clicking the Back button and to history.go(-1)) | 3 | 1 | 2 |
forward() | Loads the next URL in the history list (same as clicking the Forward button and to history.go(1)) | 3 | 1 | 2 |
go(number|"URL") | Loads a specified URL from the history list | 3 | 1 | 2 |


HTML DOM IFrame Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM IFrame Object

IFrame Object

The IFrame object represents an HTML inline frame. For each instance of an HTML <iframe> tag in a document, an IFrame object is created.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Properties

Property | Description | IE | F | N | W3C
align | Sets or returns how to align the iframe according to the surrounding text | 5 | 1 | 6 | Yes
contentDocument | Returns the document the iframe contains | - |  |  | Yes
frameBorder | Sets or returns whether to display a border for the iframe | 5 |  |  | Yes
height | Sets or returns the height of the iframe | 5 |  |  | Yes
id | Sets or returns the id of the iframe (In IE 4 this property is read-only) | 4 | 1 |  | No
longDesc | Sets or returns a URL to a long description of the iframe | 6 |  |  | Yes
marginHeight | Sets or returns the top and bottom margins of the iframe | 5 | 1 | 6 | Yes
marginWidth | Sets or returns the left and right margins of the frame | 5 | 1 | 6 | Yes
name | Sets or returns the name of the iframe | 5 |  |  | Yes
scrolling | Sets or returns whether the iframe can be scrolled | 5 | 1 | 6 | Yes
src | Sets or returns the URL to be loaded by the iframe | 5 | 1 | 6 | Yes
tabIndex | Sets or returns the index that defines the tab order for the iframe | 5 |  |  | No
width | Sets or returns the width of the iframe | 5 |  |  | Yes

Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the iframe | 5 |  |  | No
focus() | Gives focus to the iframe | 5 |  |  | No

Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the iframe loses focus | 5 |  |  | No
onFocus | Executes some code when the iframe gets focus | 5 |  |  | No


HTML DOM Image Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Image Object

Image Object

The Image object represents an HTML img element. For each instance of an HTML <img> tag in a document, an Image object is created.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Image Object Properties

Property | Description | IE | F | N | W3C
align | Sets or returns how to align the image according to the surrounding text | 5 | 1 | 6 | Yes
alt | Sets or returns an alternate text to write if the image cannot be displayed | 5 | 1 | 6 | Yes
border | Sets or returns the width of the border of the image in pixels | 4 | 1 | 3 | Yes
complete | Returns a Boolean value that indicates whether or not the browser is finished loading the image | 4 | 1 | 3 | No
height | Sets or returns the value of the height attribute of the <img> tag in pixels | 4 | 1 | 3 | Yes
hspace | Sets or returns the value of the hspace attribute of the <img> tag in pixels | 4 | 1 | 3 | Yes
id | Sets or returns the id of the image (In IE 4 this property is read-only) | 4 | 1 |  | No
isMap | Sets or returns a Boolean value that specifies if the image is a server-side image map | 5 | 1 | 6 | Yes
longDesc | Sets or returns a URL for a long description of the image | 6 |  |  | Yes
lowsrc | Sets or returns a URL to a low-resolution version of the image (for clients with low-resolution) | 4 | 1 | 3 | No
name | Sets or returns the value of the name attribute of the <img> tag | 4 | 1 | 3 | Yes
src | Sets or returns the URL of the image | 4 | 1 | 3 | Yes
useMap | Sets or returns a URL (often with a bookmark extension - #name) to use as a client-side image map | 5 | 1 | 6 | Yes
vspace | Sets or returns the value of the vspace attribute of the <img> tag in pixels | 4 | 1 | 3 | Yes
width | Sets or returns the value of the width attribute of the <img> tag in pixels | 4 | 1 | 3 | Yes

Image Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the image | 4 |  |  | No
click() | Simulates a mouse-click on the image | 4 |  |  | No
focus() | Gives focus to the image | 4 |  |  | No

Image Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onAbort | Executes some code when a user aborts the download of an image | 4 | 1 | 3 |
onBlur | Executes some code when the image loses focus | 4 |  |  |
onClick | Executes some code when a user clicks on the image | 4 |  |  |
onError | Executes some code when an Error occurs | 4 | 1 | 3 |
onFocus | Executes some code when the image gets focus | 4 |  |  |
onLoad | Executes some code when the image loads | 4 | 1 | 3 |


HTML DOM Link Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Link Object

Link Object

The Link object represents an HTML link element. The link element can only be used within the <head> tag.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Link Object Properties

Property | Description | IE | F | N | W3C
charset | Sets or returns the character set of the linked resource | 4 |  |  | Yes
disabled | Sets or returns whether or not the link object should be disabled | 4 |  |  | Yes
href | Sets or returns the URL of the linked resource | 4 | 1 | 2 | Yes
hreflang | Sets or returns the language code of the linked resource | 4 |  |  | Yes
id | Sets or returns the id of the link (In IE 4 this property is read-only) | 4 | 1 |  | No
media |  | - |  |  | Yes
name | Sets or returns the name of the link object | 4 |  |  | No
rel | Sets or returns the relationship between the current document and the target URL | 4 |  |  | Yes
rev | Sets or returns the relationship between the current document and the target URL | 4 |  |  | Yes
target | Sets or returns the window/frame where to open the target URL | 4 | 1 | 2 | Yes
type | Sets or returns the MIME type of the linked resource | 4 |  |  | Yes

Link Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onLoad | Executes some code after the browser loads the link object | 4 | 1 | 2 |


HTML DOM Location Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Location Object

Location Object

The Location object is an object that can be accessed through the location property of the Window object.

The Location object contains information about the current URL.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Location Object Properties

Property | Description | IE | F | N | W3C
hash | Sets or returns the part of the href property that follows the hash sign (#) | 3 | 1 | 2 |
host | Sets or returns the hostname and port number of the location or URL | 3 | 1 | 2 |
hostname | Sets or returns the hostname of the location or URL | 3 | 1 | 2 |
href | Sets or returns the entire URL | 3 | 1 | 2 |
pathname | Sets or returns the file name or path specified by the location object | 3 | 1 | 2 |
port | Sets or returns the port number associated with the URL | 3 | 1 | 2 |
protocol | Sets or returns the protocol part of the URL | 3 | 1 | 2 |
search | Sets or returns the part of the href property that follows the question mark (?) | 3 | 1 | 2 |

Location Object Methods

Method | Description | IE | F | N | W3C
assign("URL") | Loads a new document | 4 | 1 | 2 |
reload() | Reloads the current document | 4 | 1 | 2 |
replace("URL") | Replaces the current document with the one specified | 4 | 1 | 3 |


HTML DOM Meta Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Meta Object

Meta Object

The Meta object represents an HTML meta element.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Meta Object Properties

Property | Description | IE | F | N | W3C
charset | Sets or returns the character set used to encode the meta object | 5 | 1 | 6 | No
content | Sets or returns meta-information associated with httpEquiv or name | 5 | 1 | 6 | Yes
disabled | Sets or returns whether or not the meta object should be disabled | 5 | 1 |  | No
httpEquiv | Sets or returns information used to bind the content of the meta element to an HTTP response header | 5 | 1 | 6 | Yes
name | Sets or returns the value of the content attribute of the meta object | 5 | 1 | 6 | Yes
scheme | Sets or returns the scheme to be used in interpreting the value of a property for the meta object | 6 | 1 | 6 | Yes


HTML DOM Navigator Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Navigator Object

Navigator Object

The Navigator object is an object that can be accessed through the navigator property of the Window object.

The Navigator object contains information about the client browser.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Navigator Object Collections

Collection | Description | IE | F | N | W3C
plugins[] | Returns a reference to all embedded objects in the document | 4 | 1 | 3 |

Navigator Object Properties

Property | Description | IE | F | N | W3C
appCodeName | Returns the code name of the browser | 3 | 1 | 2 |
appMinorVersion | Returns the minor version of the browser | 4 |  |  |
appName | Returns the name of the browser | 3 | 1 | 2 |
appVersion | Returns the platform and version of the browser | 3 | 1 | 2 |
browserLanguage | Returns the current browser language | 4 |  |  |
cookieEnabled | Returns a Boolean value that specifies whether cookies are enabled in the browser | 4 | 1 | 6 |
cpuClass | Returns the CPU class of the browser's system | 4 |  |  |
onLine | Returns a Boolean value that specifies whether the system is in offline mode | 4 |  |  |
platform | Returns the operating system platform | 4 | 1 | 4 |
systemLanguage | Returns the default language used by the OS | 4 |  |  |
userAgent | Returns the value of the user-agent header sent by the client to the server | 3 | 1 | 2 |
userLanguage | Returns the OS' natural language setting | 4 |  |  |

Navigator Object Methods

Method | Description | IE | F | N | W3C
javaEnabled() | A Boolean value that specifies whether the browser has Java enabled | 4 | 1 | 3 |
taintEnabled() | A Boolean value that specifies whether the browser has data tainting enabled | 4 | 1 | 3 |


HTML DOM Object Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Object Object

Object Object

The Object object represents an HTML object element. The object element is used to place executable content on a page.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Object Properties

Property | Description | IE | F | N | W3C
align | Sets or returns the alignment of the object (according to the surrounding text) | 5 | 1 | 6 | Yes
archive | Sets or returns a string that can be used to implement your own archive functionality for the object | 6 | 1 | 6 | Yes
border | Sets or returns the width of the border around the object | - |  |  | Yes
code | Sets or returns the URL of the file that contains the compiled Java class | 5 | 1 | 6 | Yes
codeBase | Sets or returns the URL of the component | 5 | 1 | 6 | Yes
codeType |  | - |  |  | Yes
data |  | - | 1 | 6 | Yes
declare |  | - |  |  | Yes
form | Returns a reference to the object's parent form | - |  |  | Yes
height | Sets or returns the height of the object | - | 1 | 6 | Yes
hspace | Sets or returns the horizontal margin of the object | 5 | 1 | 6 | Yes
id | Sets or returns the id of the object | 4 | 1 |  | No
name | Sets or returns the name of the object | 5 | 1 | 6 | Yes
standby | Sets or returns a message when loading the object | - |  |  | Yes
tabIndex | Sets or returns the tab order of the object | 5 |  |  | Yes
type | Sets or returns the content type for data downloaded via the data attribute | - | 1 | 6 | Yes
useMap |  | - | 1 | 6 | Yes
vspace | Sets or returns the vertical margin of the object | 5 | 1 | 6 | Yes
width | Sets or returns the width of the object | - | 1 | 6 | Yes


HTML DOM Option Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Option Object

Option Object

The Option object represents a selectable option in a drop-down list in an HTML form. For each instance of an <option> tag in an HTML form, an Option object is created.

You can access an Option object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Option Object Properties

Property | Description | IE | F | N | W3C
defaultSelected | Sets or returns the value of the selected attribute of the option | 3 | 1 | 6 | Yes
disabled | Sets or returns a Boolean value that specifies whether the option should be disabled | 5 | 1 | 6 | Yes
form | Returns a reference to the form that contains the option object | 3 | 1 | 6 | Yes
id | Sets or returns the id of the option (In IE 4 this property is read-only) | 4 | 1 |  | No
index | Sets or returns the position of the option in the select box | 3 |  |  | Yes
label | Sets or returns a label for the option object | 6 |  |  | Yes
selected | Sets or returns the current state of the option | 3 | 1 | 6 | Yes
text | Sets or returns the text value for the <option> tag | 3 | 1 | 6 | Yes
value | Sets or returns the value to be returned to the server when an option is selected and the form is submitted | 3 | 1 | 6 | Yes

Option Object Methods

Method | Description | IE | F | N | W3C
click() | Simulates a mouse-click on the option | 4 |  |  | No


HTML DOM Password Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Password Object

Password Object

The Password object represents a password field in an HTML form. For each instance of an HTML <input type="password"> tag on a form, a Password object is created.

You can access a Password object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Password Object Properties

Property | Description | IE | F | N | W3C
accept | Sets or returns a list of content types, which the server processing this form will handle correctly | - |  |  | Yes
accesskey | Sets or returns the keyboard key to access the password field | 4 |  |  | Yes
defaultValue | Sets or returns the initial value of the password field | 3 | 1 | 2 | Yes
disabled | Sets or returns whether or not the password field should be disabled | 5 | 1 | 6 | Yes
form | Returns a reference to the password field's parent form | 3 | 1 | 2 | Yes
id | Sets or returns the id of the password field (In IE 4 this property is read-only) | 4 | 1 |  | No
maxLength | Sets or returns the maximum number of characters the user can enter in the password field | 4 | 1 | 6 | Yes
name | Sets or returns the name of the password field | 3 | 1 | 2 | Yes
readOnly | Sets or returns whether the content of the password field is read-only | 4 | 1 | 6 | Yes
size | Sets or returns the size of the password field | 3 | 1 | 6 | Yes
tabIndex | Sets or returns the index that defines the tab order for the password field | 4 |  |  | Yes
type | The type of the form element. For a password object it will always be "password" | 3 | 1 | 3 | Yes
value | Sets or returns the value of the value attribute of the password field | 3 | 1 | 2 | Yes

Password Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the password field | 4 | 1 | 2 | Yes
click() | Simulates a mouse-click on the password field | 4 | 1 |  | No
focus() | Sets focus on the password field | 3 | 1 | 2 | Yes
select() | Selects and highlights the entire text that is in the password field | 4 | 1 | 2 | Yes

Password Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the password field loses focus | 4 | 1 | 2 |
onClick | Executes some code when the user clicks in the password field | 4 |  |  |
onFocus | Executes some code when the password field gets focus | 3 | 1 | 2 |
onKeyDown | Executes some code when a key is pressed down in the password field | 4 | 1 | 4 |
onKeyPress | Executes some code when an alphanumeric key is pressed in the password field | 4 | 1 | 4 |
onKeyUp | Executes some code when a key is released in the password field | 4 | 1 | 4 |
onSelectStart | Executes some code when some text in the password field is selected | 4 |  |  |


HTML DOM Radio Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Radio Object

Radio Object

The Radio object represents a radio button in an HTML form. For each instance of an <input type="radio"> tag in an HTML form, a Radio object is created.

You can access a Radio object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Radio Object Properties

Property | Description | IE | F | N | W3C
accept | Sets or returns a list of content types, which the server processing this form will handle correctly | - |  |  | Yes
accesskey | Sets or returns the keyboard key to access the radio button | 4 |  |  | Yes
align | Sets or returns the alignment of the radio button according to the surrounding text | - |  |  | Yes
alt | Sets or returns an alternate text to display if the browser does not support radio buttons | - |  |  | Yes
checked | Sets or returns the current state of the radio button (true if selected and false if not selected) | 3 | 1 | 2 | Yes
defaultChecked | Sets or returns the default value of the checked attribute (true if checked by default and false if not) | 3 | 1 | 2 | Yes
disabled | Sets or returns whether or not the radio button should be disabled | 5 | 1 |  | Yes
form | Returns a reference to the radio button's parent form | 3 | 1 | 2 | Yes
id | Sets or returns the id of the radio button (In IE 4 this property is read-only) | 4 | 1 |  | No
name | Sets or returns the name of the radio button | 3 | 1 | 2 | Yes
size | Sets or returns the size of the radio button | 3 |  |  | Yes
tabIndex | Sets or returns the tab order for the radio button | 4 |  |  | Yes
type | The type of the form element. For a radio object it will always be "radio" | 3 | 1 | 3 | Yes
value | Sets or returns the value of the value attribute of the radio button | 3 | 1 | 2 | Yes

Radio Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the radio button | 4 | 1 | 2 | Yes
click() | Simulates a mouse-click on the radio button | 4 | 1 |  | Yes
focus() | Sets focus on the radio button | 3 | 1 | 2 | Yes
select() | Selects the radio button | 4 | 1 | 2 | No

Radio Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the radio button loses focus | 4 | 1 | 2 |
onClick | Executes some code when the user clicks on the radio button | 4 |  |  |
onFocus | Executes some code when the radio button gets focus | 3 | 1 | 2 |
onSelectStart | Executes some code when the radio button is selected | 4 |  |  |


HTML DOM Reset Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Reset Object

Reset Object

The Reset object represents a reset button in an HTML form. For each instance of an <input type="reset"> tag in an HTML form, a Reset object is created.

You can access a Reset object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Reset Object Properties

Property | Description | IE | F | N | W3C
accept | Sets or returns a list of content types, which the server processing this form will handle correctly | - |  |  | Yes
accesskey | Sets or returns the keyboard key to access the reset button | 4 |  |  | Yes
align | Sets or returns the alignment of the reset button according to the surrounding text | - |  |  | Yes
alt | Sets or returns an alternate text to display if the browser does not support reset buttons | - |  |  | Yes
defaultValue | Sets or returns the default value of the reset button | 3 |  |  | Yes
disabled | Sets or returns whether or not the reset button should be disabled | 5 | 1 |  | Yes
form | Returns a reference to the reset button's parent form | 3 | 1 | 2 | Yes
id | Sets or returns the id of the reset button (In IE 4 this property is read-only) | 4 | 1 |  | No
name | Sets or returns the name of the reset button | 3 | 1 | 2 | Yes
size | Sets or returns the size of the reset button | 3 |  |  | Yes
tabIndex | Sets or returns the tab order for the reset button | 4 |  |  | Yes
type | Returns the type of the form element. For a reset object it will always be "reset" | 3 | 1 | 3 | Yes
value | Sets or returns the value of the value attribute of the reset button | 3 | 1 | 2 | Yes

Reset Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the reset button | 4 | 1 | 2 | Yes
click() | Simulates a mouse-click on the reset button | 4 | 1 |  | Yes
focus() | Sets focus on the reset button | 3 | 1 | 2 | Yes
select() | Selects the reset button | 4 | 1 | 2 | No

Reset Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the reset button loses focus | 4 | 1 | 2 |
onClick | Executes some code when the user clicks on the reset button | 4 |  |  |
onFocus | Executes some code when the reset button gets focus | 3 | 1 | 2 |
onSelectStart | Executes some code when the reset button is selected | 4 |  |  |


HTML DOM Screen Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Screen Object

Screen Object

The Screen object is an object that can be accessed through the screen property of the Window object.

The Screen object contains information about the client's display screen.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Properties

Property | Description | IE | F | N | W3C
availHeight | Returns the height of the display screen - excluding the Windows Taskbar | 4 | 1 | 4 |
availWidth | Returns the width of the display screen - excluding the Windows Taskbar | 4 | 1 | 4 |
bufferDepth | Sets or returns the bit depth of the color palette in the off-screen bitmap buffer | 4 |  |  |
colorDepth | Returns the bit depth of the color palette on the destination device or buffer | 4 | 1 | 4 |
deviceXDPI | Returns the number of horizontal dots per inch of the display screen | 6 |  |  |
deviceYDPI | Returns the number of vertical dots per inch of the display screen | 6 |  |  |
fontSmoothingEnabled | Returns whether the user has enabled font smoothing in the display control panel | 4 |  |  |
height | The height of the display screen | 4 | 1 | 4 |
logicalXDPI | Returns the normal number of horizontal dots per inch of the display screen | 6 |  |  |
logicalYDPI | Returns the normal number of vertical dots per inch of the display screen | 6 |  |  |
pixelDepth | Returns the color resolution (in bits per pixel) of the display screen |  | 1 | 4 |
updateInterval | Sets or returns the update interval for the screen | 4 |  |  |
width | Returns width of the display screen | 4 | 1 | 4 |


HTML DOM Select Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Select Object

Select Object

For each instance of an HTML <select> tag on a form, a Select object is created.

You can access a Select object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

The Select object's collections, properties, methods, and events are described below:

Browser support: IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Collections

Collection | Description | IE | F | N | W3C
options | Returns an array of all the options in a dropdown list (one element for each <option> tag - starting at 0) | 3 | 1 | 2 | Yes

Properties

Property | Description | IE | F | N | W3C
accessKey | Sets or returns the keyboard key to access the dropdown list | 4 |  |  | No
align | Sets or returns the alignment of the dropdown list according to the surrounding text | 4 |  |  | No
disabled | Sets or returns whether or not the dropdown list should be disabled | 5 | 1 | 6 | Yes
form | Returns a reference to the dropdown list's parent form | 3 | 1 | 2 | Yes
id | Sets or returns the id of the dropdown list (In IE 4 this property is read-only) | 4 | 1 |  | No
length | Sets or returns the number of options in the dropdown list | 3 | 1 | 2 | Yes
multiple | Sets or returns the Boolean value indicating whether multiple items can be selected | 3 | 1 | 6 | Yes
name | Sets or returns the name of the dropdown list | 3 | 1 | 2 | Yes
selectedIndex | Sets or returns the index of the selected option in the dropdown list. Note: If the dropdown list allows for multiple selections it will only return the index of the first option selected | 3 | 1 | 2 | Yes
size | Sets or returns the number of rows in the dropdown list | 3 | 1 | 6 | Yes
tabIndex | Sets or returns the tab order for the dropdown list | 5 |  |  | Yes
type | Returns the type of the form element. For a dropdown list it will be "select-one" or "select-multiple" | 4 | 1 | 3 | Yes
value | Sets or returns the value to be returned to the server when the form is submitted | 3 | 1 | 6 | Yes

Methods

Method | Description | IE | F | N | W3C
add() | Adds an option to the dropdown list | 4 |  |  | Yes
blur() | Removes focus from the dropdown list | 4 | 1 | 3 | Yes
focus() | Sets focus on the dropdown list | 4 | 1 | 3 | Yes
remove() | Removes an option from the dropdown list | 4 | 1 | 6 | Yes

Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the dropdown list loses focus | 3 | 1 | 2 |
onChange | Executes some code when the dropdown list loses focus and its value has altered | 3 | 1 | 2 |
onClick | Executes some code when the user clicks the left mouse button in the dropdown list | 4 |  |  |
onFocus | Executes some code when the dropdown list gets focus | 4 | 1 | 2 |


HTML DOM Style object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Style Object

Style object

The Style object represents an individual style statement. The Style object can be accessed from the document or from the elements to which that style is applied.

Syntax for using the properties

document.getElementById("id").style.property_name="property_value"

The Style object's properties are described below:

  • Background
  • Border and Margin
  • Layout
  • List
  • Misc
  • Positioning
  • Printing
  • Scrollbar
  • Table
  • Text

Browser support: IE: Internet Explorer, M: Mac IE only, W: Windows IE only, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Background properties

Property | Description | Values | IE | F | N
background | Sets or returns all background properties in one | backgroundColor backgroundImage backgroundRepeat backgroundAttachment backgroundPosition | 4 | 1 | 6
backgroundAttachment | Sets or returns whether a background image is fixed or scrolls with the rest of the page | scroll fixed | 4 | 1 | 6
backgroundColor | Sets or returns the background color of the element | color-rgb color-hex color-name transparent | 4 | 1 | 6
backgroundImage | Sets or returns the background image of the element | url("URL") none | 4 | 1 | 6
backgroundPosition | Sets or returns the starting position of the background image | top left top center top right center left center center center right bottom left bottom center bottom right x-% y-% x-pos y-pos | 4 | 1 | 6
backgroundPositionX | Sets or returns the x-coordinates of the backgroundPosition property | left center right x-% x-pos | 4 |  |
backgroundPositionY | Sets or returns the y-coordinates of the backgroundPosition property | top center bottom y-% y-pos | 4 |  |
backgroundRepeat | Sets or returns if/how a background image will be repeated | repeat repeat-x repeat-y no-repeat | 4 | 1 | 6

Border and Margin properties

Property | Description | Values | IE | F | N
border | Sets or returns all properties for the four borders in one | borderWidth borderStyle borderColor | 4 | 1 | 6
borderBottom | Sets or returns all properties for the bottom border in one | borderWidth borderStyle borderColor | 4 | 1 | 6
borderLeft | Sets or returns all property for the left border in one | borderWidth borderStyle borderColor | 4 | 1 | 6
borderRight | Sets or returns all property for the right border in one | borderWidth borderStyle borderColor | 4 | 1 | 6
borderTop | Sets or returns all property for the top border in one | borderWidth borderStyle borderColor | 4 | 1 | 6
borderBottomColor | Sets or returns the color of the bottom border | borderColor | 4 | 1 | 6
borderLeftColor | Sets or returns the color of the left border | borderColor | 4 | 1 | 6
borderRightColor | Sets or returns the color of the right border | borderColor | 4 | 1 | 6
borderTopColor | Sets or returns the color of the top border | borderColor | 4 | 1 | 6
borderBottomStyle | Sets or returns the style of the bottom border | borderStyle | 4 | 1 | 6
borderLeftStyle | Sets or returns the style of the left border | borderStyle | 4 | 1 | 6
borderRightStyle | Sets or returns the style of the right border | borderStyle | 4 | 1 | 6
borderTopStyle | Sets or returns the style of the top border | borderStyle | 4 | 1 | 6
borderBottomWidth | Sets or returns the width of the bottom border | borderWidth | 4 | 1 | 6
borderLeftWidth | Sets or returns the width of the left border | borderWidth | 4 | 1 | 6
borderRightWidth | Sets or returns the width of the right border | borderWidth | 4 | 1 | 6
borderTopWidth | Sets or returns the width of the top border | borderWidth | 4 | 1 | 6
borderColor | Sets or returns the color of all four borders (can have up to four colors) | color-rgb color-hex color-name | 4 | 1 | 6
borderStyle | Sets or returns the style of all four borders | none dotted dashed solid double groove ridge inset outset | 4 | 1 | 6
borderWidth | Sets or returns the width of all four borders | thin medium thick length | 4 | 1 | 6
margin | Sets or returns the top, right, bottom, and left margins of the element | marginTop marginRight marginBottom marginLeft | 4 | 1 | 6
marginBottom | Sets or returns the bottom margin of the element | auto length % | 4 | 1 | 6
marginLeft | Sets or returns the left margin of the element | auto length % | 4 | 1 | 6
marginRight | Sets or returns the right margin of the element | auto length % | 4 | 1 | 6
marginTop | Sets or returns the top margin of the element | auto length % | 4 | 1 | 6
outline | Sets or returns the color, style, and width of the outline around the element | outlineColor outlineStyle outlineWidth | 5M | 1 | 6
outlineColor | Sets or returns the color of the outline around the element | color-rgb color-hex color-name invert | 5M | 1 | 6
outlineStyle | Sets or returns the style of the outline around the element | none dotted dashed solid double groove ridge inset outset | 5M | 1 | 6
outlineWidth | Sets or returns the width of the outline around the element | thin medium thick length | 5M | 1 | 6
padding | Sets or returns the top, right, bottom, and left padding of the element | paddingTop paddingRight paddingBottom paddingLeft | 4 | 1 | 6
paddingBottom | Sets or returns the bottom padding of the element | length % | 4 | 1 | 6
paddingLeft | Sets or returns the left padding of the element | length % | 4 | 1 | 6
paddingRight | Sets or returns the right padding of the element | length % | 4 | 1 | 6
paddingTop | Sets or returns the top padding of the element | length % | 4 | 1 | 6

Layout properties

Property | Description | Values | IE | F | N
clear | Sets or returns which sides of an element other floating elements are not allowed | left right both none | 4 | 1 | 6
clip | Sets or returns the shape of an element. What if an image is larger than the element it goes inside? - This property lets you specify the dimensions of an element that should be visible, and the element is clipped into this shape, and displayed | auto rect(top right bottom left) | 4 | 1 | 6
clipBottom | Returns the bottom coordinate of the clipping region | auto length | 5W | 1 | 6
clipLeft | Returns the left coordinate of the clipping region | auto length | 5W | 1 | 6
clipRight | Returns the right coordinate of the clipping region | auto length | 5W | 1 | 6
clipTop | Returns the top coordinate of the clipping region | auto length | 5W | 1 | 6
content | Sets or returns meta-information |  | 5M | 1 | 6
counterIncrement |  |  | 5M | 1 | 6
counterReset |  |  | 5M | 1 | 6
cssFloat |  |  | 5M | 1 | 6
cursor | Sets or returns the type of cursor to be displayed when the mouse pointer moves over the element | auto crosshair default hand pointer move e-resize ne-resize nw-resize n-resize se-resize sw-resize s-resize w-resize text wait help all-scroll (IE6+) col-resize (IE6+) no-drop (IE6+) not-allowed (IE6+) pointer (IE6+) progress (IE6+) row-resize (IE6+) url(uri) (IE6+) vertical-text (IE6+) | 4 | 1 | 6
direction | Sets or returns the reading order | ltr rtl | 5 | 1 | 6
display | Sets or returns how/if an element is displayed | block none inline inline-block list-item (IE6+) table-header-group table-footer-group | 4 | 1 | 6
filter | Sets or returns the filter/filters applied to the element |  | 4W |  |
layoutGrid |  |  | 5W |  |
layoutGridChar |  |  | 5W |  |
layoutGridLine |  |  | 5W |  |
layoutGridMode |  |  | 5W |  |
layoutGridType |  |  | 5W |  |
markerOffset |  |  | 5M | 1 | 6
marks |  |  | 5M | 1 | 6
maxHeight |  |  | 5M | 1 | 6
maxWidth |  |  | 5M | 1 | 6
minHeight |  |  | 6 | 1 | 6
minWidth |  |  | 5M | 1 | 6
MozOpacity |  |  |  | 1 | 6
overflow |  |  | 4 | 1 | 6
overflowX |  |  | 5W | 1 | 6
overflowY |  |  | 5W | 1 | 6
styleFloat |  |  | 4 |  |
verticalAlign |  |  | 4 | 1 | 6
visibility |  |  | 4 | 1 | 6
width |  |  | 4 | 1 | 6
zoom |  |  | 5W |  |

List properties

Property | Description | Values | IE | F | N
listStyle | Sets or returns all the properties for a list in one | listStyleType listStylePosition listStyleImage | 4 | 1 | 6
listStyleImage | Sets or returns the value of the image that is the list-item marker | none url(url) | 4 | 1 | 6
listStylePosition | Sets or returns where the list-item marker is placed in the list | outside inside | 4 | 1 | 6
listStyleType | Sets or returns the type of the list-item marker | disc circle square decimal lower-roman upper-roman lower-alpha upper-alpha none | 4 | 1 | 6

Misc properties

Property | Description | Values | IE | F | N
accelerator | Sets or returns a Boolean value indicating whether the element contains an accelerator key | false true | 5W |  |
behavior |  |  | 5W |  |
cssText |  |  | 4 | 1 | 6
imeMode |  |  | 5W |  |

Positioning properties

Property | Description | Values | IE | F | N
bottom |  |  | 5 | 1 | 6
height |  |  | 4 | 1 | 6
left |  |  | 4 | 1 | 6
pixelBottom |  |  | 4 |  |
pixelHeight |  |  | 4 |  |
pixelLeft |  |  | 4 |  |
pixelRight |  |  | 4 |  |
pixelTop |  |  | 4 |  |
pixelWidth |  |  | 4 |  |
posBottom |  |  | 4 |  |
posHeight |  |  | 4 |  |
posLeft |  |  | 4 |  |
posRight |  |  | 4 |  |
posTop |  |  | 4 |  |
posWidth |  |  | 4 |  |
position |  |  | 4 | 1 | 6
right |  |  | 5 | 1 | 6
top |  |  | 4 | 1 | 6
width |  |  | 4 | 1 | 6
zIndex |  |  | 4 | 1 | 6

Printing properties

Property | Description | Values | IE | F | N
orphans |  |  | 5M | 1 | 6
widows |  |  | 5M | 1 | 6
page |  |  | 5M | 1 | 6
pageBreakAfter |  |  | 4 | 1 | 6
pageBreakBefore |  |  | 4 | 1 | 6
pageBreakInside |  |  | 5M | 1 | 6
size |  |  |  | 1 | 6

Scrollbar properties

Property | Description | Values | IE | F | N
scrollbar3dLightColor |  |  | 5W |  |
scrollbarArrowColor |  |  | 5W |  |
scrollbarBaseColor |  |  | 5W |  |
scrollbarDarkShadowColor |  |  | 5W |  |
scrollbarFaceColor |  |  | 5W |  |
scrollbarHighlightColor |  |  | 5W |  |
scrollbarShadowColor |  |  | 5W |  |
scrollbarTrackColor |  |  | 5W |  |

Table properties

Property | Description | Values | IE | F | N
borderCollapse |  |  | 5M | 1 | 6
borderSpacing |  |  | 5M | 1 | 6
captionSide |  |  | 5M | 1 | 6
emptyCells |  |  | 5M | 1 | 6
tableLayout |  |  | 5 | 1 | 6

Text properties

Property | Description | Values | IE | F | N
color |  |  | 4 | 1 | 6
font |  |  | 4 | 1 | 6
fontFamily |  |  | 4 | 1 | 6
fontSize |  |  | 4 | 1 | 6
fontSizeAdjust |  |  | 5M | 1 | 6
fontStretch |  |  | 5M | 1 | 6
fontStyle |  |  | 4 | 1 | 6
fontVariant |  |  | 4 | 1 | 6
fontWeight |  |  | 4 | 1 | 6
letterSpacing |  |  | 4 | 1 | 6
lineBreak |  |  | 5 |  |
lineHeight |  |  | 4 | 1 | 6
quotes |  |  | 5M | 1 | 6
rubyAlign |  |  | 5 |  |
rubyOverhang |  |  | 5 |  |
rubyPosition |  |  | 5 |  |
textAlign |  |  | 4 | 1 | 6
textAlignLast |  |  | 5 |  |
textAutospace |  |  | 5W |  |
textDecoration |  |  | 4 | 1 | 6
textDecorationBlink |  |  | 4 |  |
textDecorationLineThrough |  |  | 4 |  |
textDecorationLineNone |  |  | 4 |  |
textDecorationLineOverline |  |  | 4 |  |
textDecorationLineUnderline |  |  | 4 |  |
textIndent |  |  | 4 | 1 | 6
textJustify |  |  | 5 |  |
textJustifyTrim |  |  | 5 |  |
textKashidaSpace |  |  | 5 |  |
textOverflow |  |  | 6W |  |
textShadow |  |  | 5M | 1 | 6
textTransform |  |  | 4 | 1 | 6
textUnderlinePosition |  |  | 5 |  |
unicodeBidi |  |  | 5 | 1 | 6
whiteSpace |  |  | 4 | 1 | 6
wordBreak |  |  | 5W |  |
wordSpacing |  |  | 6 | 1 | 6
wordWrap |  |  | 5W |  |
writingMode |  |  | 5W |  |


HTML DOM Submit Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Submit Object

Submit Object

The Submit object represents a submit button in an HTML form. For each instance of an <input type="submit"> tag in an HTML form, a Submit object is created.

You can access a Submit object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Submit Object Properties

Property | Description | IE | F | N | W3C
accept | Sets or returns a list of content types, which the server processing this form will handle correctly | - |  |  | Yes
accessKey | Sets or returns the keyboard key to access the submit button | 4 |  |  | Yes
align | Sets or returns the alignment of the submit button according to the surrounding text | - |  |  | Yes
alt | Sets or returns an alternate text to display if the browser does not support submit buttons | - |  |  | Yes
defaultValue | Sets or returns the default value of the submit button | 3 |  |  | Yes
disabled | Sets or returns whether or not the submit button should be disabled | 5 | 1 |  | Yes
form | Returns a reference to the submit button's parent form | 3 | 1 | 2 | Yes
id | Sets or returns the id of the submit button (In IE 4 this property is read-only) | 4 | 1 |  | Yes
name | Sets or returns the name of the submit button | 3 | 1 | 2 | Yes
size | Sets or returns the size of the submit button | 3 |  |  | Yes
tabIndex | Sets or returns the tab order for the submit button | 4 |  |  | Yes
type | Returns the type of the form element. For a submit object it will always be "submit" | 3 | 1 | 3 | Yes
value | Sets or returns the value of the value attribute of the submit button | 3 | 1 | 2 | Yes

Submit Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the submit button | 4 | 1 |  | Yes
click() | Simulates a mouse-click on the submit button | 4 | 1 | 2 | Yes
focus() | Sets focus on the submit button | 3 | 1 |  | Yes
select() | Selects the submit button | 4 | 1 |  | No

Submit Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the submit button loses focus | 4 |  |  |
onClick | Executes some code when the user clicks on the submit button | 4 | 1 | 2 |
onFocus | Executes some code when the submit button gets focus | 3 |  |  |
onSelectStart | Executes some code when the submit button is selected | 4 | 1 | 4 |


HTML DOM Table Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Table Object

Table Object

The Table object represents an HTML table element.

The Table object's collections, properties, methods and events are described below:

Browser support: IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Collections

Collection | Description | IE | F | N | W3C
cells[] | Returns an array containing each columns in the table | 5 |  |  | No
rows[] | Returns an array containing each row in the table | 4 | 1 | 6 | Yes
tBodies[] | Returns an array containing each tbody the table | 4 |  |  | Yes

Properties

Property | Description | IE | F | N | W3C
accessKey | Sets or returns the keyboard key to access the table | 4 | No
align | Sets or returns the alignment of the table according to the surrounding text | 4 | 1 | 6 | Yes
background | Sets or returns the background image of the table | 4 | No
bgColor | Sets or returns the background color of the table | 4 | 1 | 6 | Yes
border | Sets or returns the width of the table border | 4 | 1 | 6 | Yes
borderColor | Sets or returns the color of the table border | 5 | No
caption | Sets or returns the caption of the table | 4 | 1 | 6 | Yes
cellPadding | Sets or returns the amount of space space between the cell border and cell content | 4 | 1 | 6 | Yes
cellSpacing | Sets or returns the amount of space between cells in the table | 4 | 1 | 6 | Yes
cols | Sets or returns the number of columns in the table | 4 | No
disabled | Sets or returns whether or not the table should be disabled | 5 | No
frame Sets or returns which borders to render around the table. Possible values are:
  • void
  • above
  • below
  • hsides
  • vsides
  • lhs
  • rhs
  • box
  • border
 4 1 6 Yes
height | Sets or returns the height of the table | 4 | 1 | 6 | Yes
id | Sets or returns the id of the table (In IE 4 this property is read-only) | 4 | 1 | No
rules Sets or returns which inner-borders to display. Possible values are:
  • none
  • groups
  • rows
  • cols
  • all
 4 1 6 Yes
summary | Sets or returns a description of the table | 6 | 1 | 6 | Yes
tabIndex | Sets or returns the tab order for the table | 4 | No
tFoot | Returns the TFoot object of the table | 4 | 1 | 6 | Yes
tHead | Returns the THead object of the table | 4 | 1 | 6 | Yes
width | Sets or returns the width of the table | 4 | 1 | 6 | Yes

Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the table | 4 |  |  | No
click() | Simulates a mouse-click on the table | 4 |  |  | No
createCaption() | Creates an empty caption element in the table | 4 | 1 | 6 | Yes
createTFoot() | Creates an empty tFoot element in the table | 4 | 1 | 6 | Yes
createTHead() | Creates an empty tHead element in the table | 4 | 1 | 6 | Yes
deleteCaption() | Deletes the caption element and its content from the table | 4 | 1 | 6 | Yes
deleteRow([i]) | Deletes the specified row (tr) from the table | 4 | 1 | 6 | Yes
deleteTFoot() | Deletes the tFoot element and its content from the table | 4 | 1 | 6 | Yes
deleteTHead() | Deletes the tHead element and its content from the table | 4 | 1 | 6 | Yes
focus() | Sets focus on the table | 4 |  |  | No
insertRow([i]) | Creates a new row in the table | 4 | 1 | 6 | Yes
moveRow(from,to) | Moves a row to a new position | 5 |  |  | No
refresh() | Refreshes the content of the table | 4 |  |  | No

Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the table loses focus | 4 |  |  |
onClick | Executes some code when the user clicks on the table | 4 |  |  |
onFocus | Executes some code when the table gets focus | 4 |  |  |
onSelectStart | Executes some code when the table is selected | 4 |  |  |


HTML DOM TableData Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM TableData Object

TableData Object

The TableData object represents an HTML td element.

The TableData object's properties, methods and events are described below:

Browser support: IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Properties

Property | Description | IE | F | N | W3C
abbr | Sets or returns an abbreviated text for the table cell (for non-visual media such as speech or Braille) | 6 |  |  | Yes
accessKey | Sets or returns the keyboard key to access the table cell | 4 |  |  | No
align | Sets or returns the horizontal alignment of data within the table cell | 4 |  |  | Yes
axis | Sets or returns a comma-delimited list of related table cells (categories) | 6 |  |  | Yes
background | Sets or returns the background image for the table cell | 4 |  |  | No
bgColor | Sets or returns the background color for the table cell | 4 |  |  | Yes
borderColor | Sets or returns the border color of the table cell | 4 |  |  | No
cellIndex | Returns the position of the cell in the cells collection of a row | 4 |  |  | Yes
ch | Sets or returns the alignment character for the table cell | 6 |  |  | Yes
chOff | Sets or returns the offset of alignment character for the table cell | 6 |  |  | Yes
colSpan | Sets or returns the number of columns the table cell should span | 4 |  |  | Yes
disabled | Sets or returns whether or not the table cell should be disabled | 5 |  |  | No
headers | Sets or returns a list of space-separated header cell ids | 6 |  |  | Yes
height | Sets or returns the height of the table cell | 4 |  |  | No
id | Sets or returns the id of the table cell (In IE 4 this property is read-only) | 4 |  |  | No
innerHTML | Sets or returns the HTML between the start and end tags of the table cell | 4 |  |  | No
innerText | Sets or returns the text between the start and end tags of the table cell | 4 |  |  | No
noWrap | Sets or returns a Boolean value indicating whether or not the browser automatically performs word wrap in the table cell | 4 |  |  | Yes
outerHTML | Sets or returns the table data object and its content in HTML | 4 |  |  | No
outerText | Sets or returns the text of the table data object | 4 |  |  | No
rowSpan | Sets or returns the number of rows the table cell should span | 4 |  |  | Yes
scope |  | 6 |  |  | Yes
tabIndex | Sets or returns the tab order for the table cell | 4 |  |  | No
vAlign | Sets or returns how cell content are vertically aligned | 4 |  |  | Yes
width | Sets or returns the width of the table cell | 4 |  |  | Yes

Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the table cell | 4 |  |  | No
click() | Simulates a mouse-click on the table cell | 4 |  |  | No
focus() | Sets focus on the table cell | 4 |  |  | No

Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the table cell loses focus | 4 |  |  |
onClick | Executes some code when the user clicks on the table cell | 4 |  |  |
onFocus | Executes some code when the table cell gets focus | 4 |  |  |
onSelectStart | Executes some code when the table cell is selected | 4 |  |  |


HTML DOM TableHeader Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM TableHeader Object

TableHeader Object

The TableHeader object represents an HTML th element.

The TableHeader object's properties, methods and events are described below:

Browser support: IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Properties

Property | Description | IE | F | N | W3C
abbr | Sets or returns an abbreviated text for the table header cell (for non-visual media such as speech or Braille) | 6 |  |  | Yes
accessKey | Sets or returns the keyboard key to access the table header cell | 5 |  |  | No
align | Sets or returns the horizontal alignment of data within the table header cell | 4 |  |  | Yes
axis | Sets or returns a comma-delimited list of related table header cells (categories) | 6 |  |  | Yes
background | Sets or returns the background image for the table header cell | 4 |  |  | No
bgColor | Sets or returns the background color for the table header cell | 4 |  |  | Yes
borderColor | Sets or returns the border color of the table header cell | 4 |  |  | No
cellIndex | Returns the position of the cell in the cells collection of a row | 4 |  |  | Yes
ch | Sets or returns the alignment character for the table header cell | 6 |  |  | Yes
chOff | Sets or returns the offset of alignment character for the table header cell | 6 |  |  | Yes
colSpan | Sets or returns the number of columns the table header cell should span | 4 |  |  | Yes
headers | Sets or returns a list of space-separated header cell ids | 6 |  |  | Yes
height | Sets or returns the height of the table header cell | 4 |  |  | No
id | Sets or returns the id of the table header cell (In IE 4 this property is read-only) | 4 |  |  | No
innerHTML | Sets or returns the HTML between the start and end tags of the table header cell | 4 |  |  | No
innerText | Sets or returns the text between the start and end tags of the table header cell | 4 |  |  | No
noWrap | Sets or returns a Boolean value indicating whether or not the browser automatically performs word wrap in the table header cell | 4 |  |  | Yes
outerHTML | Sets or returns the table header object and its content in HTML | 4 |  |  | No
outerText | Sets or returns the text of the table header object | 4 |  |  | No
rowSpan | Sets or returns the number of rows the table header cell should span | 4 |  |  | Yes
scope |  | 6 |  |  | Yes
tabIndex | Sets or returns the tab order for the table header cell | 5 |  |  | No
vAlign | Sets or returns how header cell content are vertically aligned | 4 |  |  | Yes
width | Sets or returns the width of the table header cell | 4 |  |  | Yes

Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the table header cell | 5 |  |  | No
click() | Simulates a mouse-click on the table header cell | 4 |  |  | No
focus() | Sets focus on the table header cell | 5 |  |  | No

Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the table header cell loses focus | 5 |  |  |
onClick | Executes some code when the user clicks on the table header cell | 4 |  |  |
onFocus | Executes some code when the table header cell gets focus | 5 |  |  |
onSelectStart | Executes some code when the table header cell is selected | 4 |  |  |


HTML DOM TableRow Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM TableRow Object

TableRow Object

The TableRow object represents an HTML tr element.

The TableRow object's collections, properties, methods and events are described below:

Browser support: IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Collections

Collection | Description | IE | F | N | W3C
cells[] | Returns an array containing each column in the table row | 4 |  |  | Yes

Properties

Property | Description | IE | F | N | W3C
accessKey | Sets or returns the keyboard key to access the table row | 5 |  |  | No
align | Sets or returns the horizontal alignment of data within cells of the table row | 4 |  |  | Yes
bgColor | Sets or returns the background color for the table row | 4 |  |  | Yes
borderColor | Sets or returns the border color of the table row | 4 |  |  | No
ch | Sets or returns the alignment character for cells in the table row | 6 |  |  | Yes
chOff | Sets or returns the offset of alignment character for cells in the table row | 6 |  |  | Yes
disabled | Sets or returns whether or not the table row should be disabled | 5.5 |  |  | No
height | Sets or returns the height of the table row | 5 |  |  | No
id | Sets or returns the id of the table row (In IE 4 this property is read-only) | 4 |  |  | No
innerHTML | Sets or returns the HTML between the start and end tags of the table row | 5 |  |  | No
innerText | Sets or returns the text between the start and end tags of the table row | 5 |  |  | No
outerHTML | Sets or returns the table row object and its content in HTML | 4 |  |  | No
outerText | Sets or returns the text of the table row object | 4 |  |  | No
rowIndex | Returns the table row object's position in the rows collection for the table | 4 |  |  | Yes
sectionRowIndex | Returns the table rows object's position in the tBody, tHead, or tFoot rows collection | 4 |  |  | Yes
tabIndex | Sets or returns the tab order for the table row | 5 |  |  | No
vAlign | Sets or returns how cell content are vertically aligned within the table row | 4 |  |  | Yes
width | Sets or returns the width of the table row | 4 |  |  | No

Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the table row | 4 |  |  | No
click() | Simulates a mouse-click on the table row | 4 |  |  | No
deleteCell([i]) | Deletes a cell in the table row | 4 |  |  | Yes
focus() | Sets focus on the table row | 5 |  |  | No
insertCell([i]) | Creates a new cell in the table row | 4 |  |  | Yes

Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the table row loses focus | 4 |  |  |
onClick | Executes some code when the user clicks on the table row | 4 |  |  |
onFocus | Executes some code when the table row gets focus | 4 |  |  |
onSelectStart | Executes some code when the table row is selected | 4 |  |  |


HTML DOM Text Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Text Object

Text Object

The Text object represents a text field in an HTML form. For each instance of an <input type="text"> tag in an HTML form, a Text object is created.

You can access a Text object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Text Object Properties

Property | Description | IE | F | N | W3C
accept | Sets or returns a list of content types, which the server processing this form will handle correctly | - |  |  | Yes
accessKey | Sets or returns the keyboard key to access the text field | 4 | - | - | Yes
align | Sets or returns the alignment of the text field according to the surrounding text | - |  |  | Yes
alt | Sets or returns an alternate text to display if the browser does not support text fields | - |  |  | Yes
defaultValue | Sets or returns the initial value of the text field | 3 | 1 | 2 | Yes
disabled | Sets or returns whether or not the text field should be disabled | 5 | 1 | 6 | Yes
form | Returns a reference to the text field's parent form | 3 | 1 | 2 | Yes
id | Sets or returns the id of the text field (In IE 4 this property is read-only) | 4 | 1 |  | No
maxLength | Sets or returns the maximum number of characters in the text field | 4 | 1 | 6 | Yes
name | Sets or returns the name of the text field | 3 | 1 | 2 | Yes
readOnly | Sets or returns whether or not the text field should be read-only | 4 | 1 | 6 | Yes
size | Sets or returns the size of the text field | 3 | 1 | 6 | Yes
tabIndex | Sets or returns the tab order for the text field | 4 |  |  | Yes
type | Returns the type of the form element. For a text object it will always be "text" | 3 | 1 | 3 | Yes
value | Sets or returns the value of the value attribute of the text field | 3 | 1 | 2 | Yes

Text Object Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the text field | 4 | 1 | 2 | Yes
click() | Simulates a mouse-click in the text field | 4 |  |  | No
focus() | Sets focus on the text field | 3 | 1 | 2 | Yes
select() | Selects the content of the text field | 4 | 1 | 2 | Yes

Text Object Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the text field loses focus | 4 | 1 | 2 |
onChange | Executes some code when the text field loses focus and its value has altered | 3 | 1 | 2 |
onClick | Executes some code when the user clicks the left mouse button in the text field | 4 |  |  |
onFocus | Executes some code when the text field gets focus | 3 | 1 | 2 |
onKeyDown | Executes some code when a key is pressed in the text field | 4 | 1 | 4 |
onKeyPress | Executes some code when an alphanumeric key is pressed in the text field | 4 | 1 | 4 |
onKeyUp | Executes some code when a key is released in the text field | 4 | 1 | 4 |
onSelect | Executes some code when the current selection is changed in the text field | 3 | 1 | 2 |
onSelectStart | Executes some code when some text in the text field is selected | 4 |  |  |


HTML DOM Textarea Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Textarea Object

Textarea Object

For each instance of an HTML <textarea> tag on a form, a Textarea object is created.

You can access a Textarea object by indexing the elements array (by number or name) of the corresponding form or by using getElementById().

The Textarea object's properties, methods, and events are described below:

Browser support: IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Properties

Property | Description | IE | F | N | W3C
accessKey | Sets or returns the keyboard key to access the textarea | 4 |  |  | Yes
cols | Sets or returns the width (in characters) of the textarea | 3 | 1 | 6 | Yes
defaultValue | Sets or returns the initial contents of the textarea | 3 |  |  | Yes
disabled | Sets or returns whether or not the textarea should be disabled | 5 | 1 | 6 | Yes
form | Returns a reference to the textarea's parent form | 3 | 1 | 2 | Yes
id | Sets or returns the id of the textarea (In IE 4 this property is read-only) | 4 | 1 |  | No
name | Sets or returns the name of the textarea | 3 | 1 | 2 | Yes
readOnly | Sets or returns whether or not the textarea should be read-only | 4 | 1 | 6 | Yes
rows | Sets or returns the height (in rows) of the textarea | 3 | 1 | 6 | Yes
tabIndex | Sets or returns the tab order for the textarea | 4 |  |  | Yes
type | Returns the type of the form element. For a textarea object it will always be "textarea" | 3 | 1 | 3 | Yes
value | Sets or returns the text in the textarea | 3 | 1 | 2 | Yes

Methods

Method | Description | IE | F | N | W3C
blur() | Removes focus from the textarea | 3 | 1 | 2 | Yes
click() | Simulates a mouse-click in the textarea | 4 |  |  | No
focus() | Sets focus on the textarea | 3 | 1 | 2 | Yes
select() | Selects and highlights the entire text that is in the textarea | 4 | 1 | 2 | Yes

Events

Syntax: object.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when the textarea loses focus | 3 | 1 | 2 |
onChange | Executes some code when the textarea loses focus and its value has altered | 3 | 1 | 2 |
onClick | Executes some code when the user clicks the left mouse button in the textarea | 4 |  |  |
onFocus | Executes some code when the textarea gets focus | 3 | 1 | 2 |
onKeyDown | Executes some code when a key is pressed down in the textarea |  | 1 | 4 |
onKeyPress | Executes some code when a key is pressed in the textarea |  | 1 | 4 |
onKeyUp | Executes some code when a key is released in the textarea |  | 1 | 4 |
onSelect | Executes some code when some text in the textarea is selected |  | 1 | 2 |


HTML DOM Window Object

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Window Object

Window Object

The Window object corresponds to the browser window. A Window object is created automatically with every instance of a <body> or <frame> tag.

The Window object's collections, objects, properties, methods, and events are described below:

Browser support: IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Collections

Collection | Description | IE | F | N | W3C
frames[] | Returns all named frames in the window | 3 | 1 | 2 |

Objects

Object | Description | IE | F | N | W3C
clientInformation | Contains information about the browser | 4 |  |  |
clipboardData |  | 5 |  |  |
document | Represents the HTML document object in the window. See Document object | 3 |  |  |
event | Represents the state of an event | 4 |  |  |
external |  | 4 |  |  |
history | Contains the URLs visited from the window. See History object | 3 |  |  |
location | Contains the current URL of the window. See Location object | 3 |  |  |
navigator | Contains information about the browser. See Navigator object | 3 |  |  |
screen | Contains information about the client's screen. See Screen object | 4 |  |  |

Properties

Property | Description | IE | F | N | W3C
closed | Returns a Boolean value that specifies whether the referenced window has been closed | 4 | 1 | 3 |
defaultStatus | Sets or returns the default text in the statusbar of the windows (will be displayed when the page loads) | 3 | 1 | 2 |
dialogArguments | Returns all variables passed into the modal dialog window | 4 |  |  |
dialogHeight | Sets or returns the height of the modal dialog window | 4 |  |  |
dialogLeft | Sets or returns the left coordinates of the modal dialog window | 4 |  |  |
dialogTop | Sets or returns the top coordinates of the modal dialog window | 4 |  |  |
dialogWidth | Sets or returns the width of the modal dialog window | 4 |  |  |
frameElement | Returns the frame/iframe object that is hosting the window in the parent document | 5 |  |  |
length | Sets or returns the number of frames in the window | 4 | 1 | 6 |
name | Sets or returns the name of the window | 3 | 1 | 2 |
offscreenBuffering | Sets or returns a Boolean value that specifies whether the window is drawn offscreen before being visible to the user | 4 |  |  |
opener | Sets or returns a reference to the window that created the window | 4 | 1 | 3 |
parent | Returns the parent window | 3 | 1 | 2 |
returnValue | Sets or returns the value returned from the modal dialog window | 4 |  |  |
screenLeft | Returns the x-coordinate of the upper left corner of the browser - relative to the upper left corner of the screen | 5 |  |  |
screenTop | Returns the y-coordinate of the top corner of the browser - relative to the top corner of the screen | 5 |  |  |
self | Returns a reference to the current window | 3 | 1 | 2 |
status | Sets or returns the text in the statusbar of the window | 3 | 1 | 2 |
top | Returns the topmost ancestor window | 3 | 1 | 2 |

Methods

Method | Description | IE | F | N | W3C
alert("msg") | Displays an alert box with a message and an OK button | 3 | 1 | 2
attachEvent("event",pointer) | 5
blur() | Removes focus from the current window | 4 | 1 | 3
clearInterval(ID) | Cancels a timeout that is set with the setInterval() method | 4 | 1 | 4
clearTimeout(ID) | Cancels a timeout that is set with the setTimeout() method | 3 | 1 | 2
close() | Closes the current window | 3 | 1 | 2
confirm("msg") | Displays a dialog box with a message, a Cancel, and an OK button | 3 | 1 | 2
createPopup([args]) | Creates a pop-up window | 5
execScript("code", "lang")

Executes a specified script. The arguments can take the following values:

code | Required. The code to be executed
lang | Required. JScript | VBScript | JavaScript

 4
focus() | Sets focus on the current window | 4 | 1 | 3
moveBy(x,y) | Moves the window a specified number of pixels in relation to its current co-ordinates | 4 | 1 | 4
moveTo(x,y) | Moves the window's left and top edge to the specified co-ordinates | 4 | 1 | 4
navigate("URL") | Loads the specified URL into the window | 3
open(["URL", "name", "specs", replace]) Opens a new browser window. The arguments can take the following values:

"URL" - Optional. Specifies the URL of the page to display if no URL is specified, a new window with about:blank is displayed)

"name" - Optional. Specifies the value for the target attribute on a form or a link. The following values are supported:

_blank | URL is loaded into a new window
_media | URL is loaded into the content area of the Media Bar (IE6+)
_parent | URL is loaded into the parent frame
_search | URL is opened in the browser's search pane (IE5+)
_self | URL replaces the current page
_top | URL replaces any framesets that may be loaded

"specs" - Optional. A comma-separated list of items. The following values are supported:

channelmode = yes | no | 1 | 0 | whether to display the window in theater mode. Default is no
directories = yes | no | 1 | 0 | whether to add directory buttons. Default is yes
fullscreen = yes | no | 1 | 0 | whether to display the browser in full-screen mode. Default is no. A window in full-screen mode must also be in theater mode
height = number | the height of the window, in pixels. Min. value is 100
left = number | the left position, in pixels
location = yes | no | 1 | 0 | whether to display the address field. Default is yes
menubar = yes | no | 1 | 0 | whether to display the menu bar. Default is yes
resizable = yes | no | 1 | 0 | whether the window is resizable. Default is yes
scrollbars = yes | no | 1 | 0 | whether to display scroll bars. Default is yes
status = yes | no | 1 | 0 | whether to add a status bar. Default is yes
titlebar = yes | no | 1 | 0 | whether to display the title bar. Ignored unless the calling application is an HTML Application or a trusted dialog box. Default is yes
toolbar = yes | no | 1 | 0 | whether to display the browser toolbar. Default is yes
top = number | the top position, in pixels
width = number | the width of the window, in pixels. Min. value is 100

replace - Optional.Specifies whether the URL creates a new entry or replaces the current entry in the history list. The following values are supported:

true | URL replaces the current document in the history list
false | URL creates a new entry in the history list

 3
print() | Prints the contents of the current window | 5 | 1 | 4
prompt(["msg", "default"])

Displays a dialog box prompting the user for input. The arguments can take the following values:

msg | Optional. The message to display in the dialog box. Default is ""
default | Optional. The default text in the input field

 3 1 2
resizeBy(x,y) | Resizes the window by the specified pixels. Note: This method does not work on dialog windows | 4
resizeTo(width, height) | Resizes the window to the specified width and height. Note: This method does not work on dialog windows | 4
scroll(x,y) | Deprecated. Use scrollTo() instead. | 4
scrollBy(x,y) | Scrolls the content by the specified number of pixels. Note: The visible property of the window's scrollbar must be set to true if using this method | 4 | 1 | 4
scrollTo(x,y) | Scrolls the content to the specified co-ordinates | 4 | 1 | 4
setActive() | 5
setInterval(code, millisec[, "lang"])

Calls a function / evaluate an expression every time a specified interval (in milliseconds) has been reached. The arguments can take the following values:

code | Required. A pointer to a function or the code to be executed
millisec | Required. The number of milliseconds
lang | Optional. JScript | VBScript | JavaScript

 4 1 4
setTimeout(code, millisec[, "lang"])

Calls a function / evaluate an expression after a specified number of milliseconds. The arguments can take the following values:

code | Required. A pointer to a function or the code to be executed
millisec | Required. The number of milliseconds
lang | Optional. JScript | VBScript | JavaScript

 3 1 2
showHelp("URL"[, contextID])

Displays a Help file (must be of type .htm or .chm). When using this method, a second Help box appears when pressing F1 or when clicking Help on the menu bar. To prevent the default Help box from appearing set returnValue to false. The arguments can take the following values:

URL | Required. The URL of a Help file
contextID | Optional. A string or integer that specifies a context identifier in the Help file

 4
showModalDialog("URL"[, args, "list"]) Loads a URL in a modal dialog box. A modal dialog box retains focus while open. The user CANNOT switch windows until the dialog box is closed. The arguments can take the following values:

"URL" - Required. The URL of the document to display.

args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object.

"list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:

dialogHeight : number | the height* of the dialog window
dialogLeft : number | the left position of the dialog window
dialogTop : number | the top position of the dialog window
dialogWidth : number | the width* of the dialog window
center : yes | no | 1 | 0 | on | off | whether to center the dialog window within the desktop. Default is yes
dialogHide : yes | no | 1 | 0 | on | off | whether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
edge : sunken | raised | the edge style of the dialog window. Default is raised
help : yes | no | 1 | 0 | on | off | whether the dialog window displays the Help icon. Default is yes
resizable : yes | no | 1 | 0 | on | off | whether the dialog window is resizable. Default is no
scroll : yes | no | 1 | 0 | on | off | whether the dialog window displays scrollbars. Default is yes
status : yes | no | 1 | 0 | on | off | whether the dialog window displays a status bar. Default is yes for untrusted dialog windows and no for trusted dialog windows
unadorned : yes | no | 1 | 0 | on | off | whether the dialog window displays the border window chrome. Only available when a dialog window is opened from a trusted application. Default is no

 4
showModelessDialog("URL"[, args, "list"]) Loads a URL in a modeless dialog box. The modeless dialog box displays even when the user switches focus to another window (useful for menus and Help systems). The arguments can take the following values:

"URL" - Required. The URL of the document to display.

args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object.

"list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:

dialogHeight : number | the height* of the dialog window
dialogLeft : number | the left position of the dialog window
dialogTop : number | the top position of the dialog window
dialogWidth : number | the width* of the dialog window
center : yes | no | 1 | 0 | on | off | whether to center the dialog window within the desktop. Default is yes
dialogHide : yes | no | 1 | 0 | on | off | whether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
edge : sunken | raised | the edge style of the dialog window. Default is raised
help : yes | no | 1 | 0 | on | off | whether the dialog window displays the Help icon. Default is yes
resizable : yes | no | 1 | 0 | on | off | whether the dialog window is resizable. Default is no
scroll : yes | no | 1 | 0 | on | off | whether the dialog window displays scrollbars. Default is yes
status : yes | no | 1 | 0 | on | off | whether the dialog window displays a status bar. Default is yes for untrusted dialog windows and no for trusted dialog windows
unadorned : yes | no | 1 | 0 | on | off | whether the dialog window displays the border window chrome. Only available when a dialog window is opened from a trusted application. Default is no

 5

* The default unit of measure for dialogHeight and dialogWidth in IE4 is em; in IE5 it is px. Other values to use: cm, mm, in, pt, pc, or ex. For consistent results, use px! Note: The min. dialogHeight you can specify is 100px.

Events

Syntax: window.event_name="someJavaScriptCode"

Event | Description | IE | F | N | W3C
onBlur | Executes some code when a Blur event occurs |  | 1 | 3 |
onError | Executes some code when an Error event occurs |  | 1 | 3 |
onFocus | Executes some code when a Focus event occurs |  | 1 | 3 |
onLoad | Executes some code when an Load event occurs |  | 1 | 2 |
onResize | Executes some code when a Resize event occurs |  | 1 | 4 |
onUnload | Executes some code when an Unload event occurs |  | 1 | 2 |


HTML DOM Reference

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

HTML DOM Reference

HTML DOM Objects

Follow the links to learn more about the objects and their collections, properties, methods and events.

Object | Description
Anchor | Represents an HTML a element (a hyperlink)
Applet | Represents an HTML applet element. The applet element is used to place executable content on a page
Area | Represents an area of an image-map. An image-map is an image with clickable regions
Base | Represents an HTML base element
Basefont | Represents an HTML basefont element
Body | Represents the body of the document (the HTML body)
Button | Represents a push button on an HTML form. For each instance of an HTML <input type="button"> tag on an HTML form, a Button object is created
Checkbox | Represents a checkbox on an HTML form. For each instance of an HTML <input type="checkbox"> tag on an HTML form, a Checkbox object is created
Document | Used to access all elements in a page
Event | Represents the state of an event, such as the element in which the event occurred, the state of the keyboard keys, the location of the mouse, and the state of the mouse buttons
FileUpload | For each instance of an HTML <input type="file"> tag on a form, a FileUpload object is created
Form | Forms are used to prompt users for input. Represents an HTML form element
Frame | Represents an HTML frame
Frameset | Represents an HTML frameset
Hidden | Represents a hidden field on an HTML form. For each instance of an HTML <input type="hidden"> tag on a form, a Hidden object is created
History | A predefined object which can be accessed through the history property of the Window object. This object consists of an array of URLs. These URLs are all the URLs the user has visited within a browser window
Iframe | Represents an HTML inline-frame
Image | Represents an HTML img element
Link | Represents an HTML link element. The link element can only be used within the <head> tag
Location | Contains information about the current URL
Meta | Represents an HTML meta element
Navigator | Contains information about the client browser
Option | Represents an option in a selection list on an HTML form. For each instance of an HTML <option> tag in a selection list on a form, an Option object is created
Password | Represents a password field on an HTML form. For each instance of an HTML <input type="password"> tag on a form, a Password object is created
Radio | Represents radio buttons on an HTML form. For each instance of an HTML <input type="radio"> tag on a form, a Radio object is created
Reset | Represents a reset button on an HTML form. For each instance of an HTML <input type="reset"> tag on a form, a Reset object is created
Screen | Automatically created by the JavaScript runtime engine and it contains information about the client's display screen
Select | Represents a selection list on an HTML form. For each instance of an HTML <select> tag on a form, a Select object is created
Style | Represents an individual style statement. This object can be accessed from the document or from the elements to which that style is applied
Submit | Represents a submit button on an HTML form. For each instance of an HTML <input type="submit"> tag on a form, a Submit object is created
Table | Represents an HTML table element
TableData | Represents an HTML td element
TableHeader | Represents an HTML th element
TableRow | Represents an HTML tr element
Text | Represents a text field on an HTML form. For each instance of an HTML <input type="text"> tag on a form, a Text object is created
Textarea | Represents an HTML textarea element
Window | Corresponds to the browser window. A Window object is created automatically with every instance of a <body> or <frameset> tag


The blur() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The blur() method

Definition and Usage

The blur() method is used to remove focus from a link.

Syntax

anchorObject.blur()

Example

<html>
<head>
<style type="text/css">
a:active {color:green}
</style>
<script type="text/javascript">
function getfocus()
{document.getElementById('myAnchor').focus()}
function losefocus()
{document.getElementById('myAnchor').blur()}
</script>
</head>
<body>
<a id="myAnchor"
href="http://www.w3schools.com">Visit W3Schools.com</a>
<br /><br/>
<input type="button" onclick="getfocus()" value="Get focus">
<input type="button" onclick="losefocus()" value="Lose focus">
</body>
</html>


The focus() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The focus() method

Definition and Usage

The focus() method is used to give focus to a link.

Syntax

anchorObject.focus()

Example

<html>
<head>
<style type="text/css">
a:active {color:green}
</style>
<script type="text/javascript">
function getfocus()
{document.getElementById('myAnchor').focus()}
function losefocus()
{document.getElementById('myAnchor').blur()}
</script>
</head>
<body>
<a id="myAnchor"
href="http://www.w3schools.com">Visit W3Schools.com</a>
<br /><br/>
<input type="button" onclick="getfocus()" value="Get focus">
<input type="button" onclick="losefocus()" value="Lose focus">
</body>
</html>


The close() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The close() method

Definition and Usage

The close() method closes the output stream and displays the sent data.

Syntax

document.close()

Example

<html>
<head>
<script>
function createNewDoc()
{
var newDoc=document.open("text/html","replace")
var txt="<html><body>Learning about the DOM is FUN!</body></html>"
newDoc.write(txt)
newDoc.close()
}
</script>
</head>
<body>
<input type="button" value="Open and write to a new document"
onclick="createNewDoc()">
</body>
</html>


The getElementById() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The getElementById() method

Definition and Usage

The getElementById() method returns a reference to the first object with the specified ID.

Syntax

document.getElementById(id)

Example

<html>
<head>
<script type="text/javascript">
function getElement()
{
var x=document.getElementById("myHeader")
alert("I am a " + x.tagName + " element")
}
</script>
</head>
<body>
<h1 id="myHeader" onclick="getElement()">
Click to see what element I am!</h1>
</body>
</html>


The getElementsByName() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The getElementsByName() method

Definition and Usage

The getElementsByName() method returns a collection of objects with the specified NAME.

Syntax

document.getElementsByName(name)

Example

<html>
<head>
<script type="text/javascript">
function getElements()
{
var x=document.getElementsByName("myInput")
alert(x.length + " elements!")
}
</script>
</head>
<body>
<input name="myInput" type="text" size="20"><br />
<input name="myInput" type="text" size="20"><br />
<input name="myInput" type="text" size="20"><br />
<br />
<input type="button" onclick="getElements()"
value="How many elements named 'myInput'?">
</body>
</html>


The open() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The open() method

Definition and Usage

The open() method opens a document for writing.

If a document exists in the target it will be cleared. If this method has no arguments, a new window with about:blank is displayed.

Syntax

document.open("mimetype"[,replace])

Example

<html>
<head>
<script>
function createNewDoc()
{
var newDoc=document.open("text/html","replace")
var txt="<html><body>Learning about the DOM is FUN!</body></html>"
newDoc.write(txt)
newDoc.close()
}
</script>
</head>
<body>
<input type="button" value="Open and write to a new document"
onclick="createNewDoc()">
</body>
</html>


The write() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The write() method

Definition and Usage

The write() method writes a text string to a document.

Syntax

document.write(string)

Example

<html>
<body>
<script type="text/javascript">
document.write("Hello World!")
</script>
</body>
</html>


The reset() Method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The reset() Method

Definition and Usage

The reset() method resets the default values of all elements in the form (same as clicking the Reset button).

Syntax

formObject.reset()

Example

<html>
<head>
<script type="text/javascript">
function formReset()
{
document.getElementById("myForm").reset()
}
</script>
</head>
<form id="myForm">
Name: <input type="text" size="20"><br />
Age: <input type="text" size="20"><br />
<br />
<input type="button" onclick="formReset()" value="Reset">
</form>
</body>
</html>


The submit() Method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The submit() Method

Definition and Usage

The submit() method submits the form (same as clicking the Submit button).

Syntax

formObject.submit()

Example

<html>
<head>
<script type="text/javascript">
function formSubmit()
{
document.getElementById("myForm").submit()
}
</script>
</head>
<body>

<form id="myForm" action="js_form_action.asp" method="get">
Firstname: <input type="text" name="firstname" size="20"><br />
Lastname: <input type="text" name="lastname" size="20"><br />
<br />
<input type="button" onclick="formSubmit()" value="Submit">
</form>
</body>
</html>


The reload() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The reload() method

Definition and Usage

The reload() method is used to reload the current document.

Syntax

window.location.reload()

Example

<html>
<head>
<script type="text/javascript">
function reload()
{
window.location.reload()
}
</script>
</head>
<body>
<input type="button" value="Reload page" onclick="reload()">
</body>
</html>


The focus() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The focus() method

Definition and Usage

The focus() method is used to give focus to a text field.

Syntax

textObject.focus()

Example

<html>
<head>
<script type="text/javascript">
function setFocus()
{
document.getElementById("fname").focus()
}
</script>
</head>
<body onload="setFocus()">
<form>
Name: <input type="text" id="fname" size="30"><br />
Age: <input type="text" id="age" size="30">
</form>
</body>
</html>


The select() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The select() method

Definition and Usage

The select() method is used to select the content of a text field.

Syntax

textObject.select()

Example

<html>
<head>
<script type="text/javascript">
function selText()
{
document.getElementById("myText").select()
}
</script>
</head>
<body>
<form>
<input size="40" type="text" id="myText"
value="A cat played with a ball in the garden">
<input type="button" value="Select text"
onclick="selText()">
</form>
</body>
</html>


The accessKey Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The accessKey Property

Definition and Usage

The accessKey property sets or returns a keyboard key to access a link.

Note: Use Alt + accessKey to give focus to the elements with a specified access key.

Syntax

anchorObject.accessKey=accessKey

Example

<html>
<head>
<script type="text/javascript">
function access()
{
document.getElementById('myAnchor').accessKey="a"
}
</script>
</head>

<body onload="access()">
<p><a id="myAnchor" href="http://www.w3schools.com">
Visit W3Schools.com</a></p>
</body>

</html>


The href Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The href Property

Definition and Usage

The href property sets or returns the URL of the linked resource.

Syntax

anchorObject.href=URL

Example

<html>
<head>
<script type="text/javascript">
function changeLink()
{
document.getElementById('myLink').innerHTML="W3Schools"
document.getElementById('myLink').href="http://www.w3schools.com"
document.getElementById('myAnchor').target="_blank"
}
</script>
</head>
<body>
<a id="myLink" href="http://www.microsoft.com">Microsoft</a>
<br /><br />
<input type="button" onclick="changeLink()" value="Change link">
</body>
</html>


The innerHTML Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The innerHTML Property

Definition and Usage

The innerHTML property sets or returns the text of the link.

Syntax

anchorObject.innerHTML=text

Example

<html>
<head>
<script type="text/javascript">
function changeLink()
{
document.getElementById('myLink').innerHTML="W3Schools"
document.getElementById('myLink').href="http://www.w3schools.com"
document.getElementById('myAnchor').target="_blank"
}
</script>
</head>
<body>
<a id="myLink" href="http://www.microsoft.com">Microsoft</a>
<br /><br />
<input type="button" onclick="changeLink()" value="Change link">
</body>
</html>


The target Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The target Property

Definition and Usage

The target property sets or returns where to open the target URL.

Syntax

anchorObject.target=target

Example

<html>
<head>
<script type="text/javascript">
function changeLink()
{
document.getElementById('myLink').innerHTML="W3Schools"
document.getElementById('myLink').href="http://www.w3schools.com"
document.getElementById('myAnchor').target="_blank"
}
</script>
</head>
<body>
<a id="myLink" href="http://www.microsoft.com">Microsoft</a>
<br /><br />
<input type="button" onclick="changeLink()" value="Change link">
</body>
</html>


The disabled Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The disabled Property

Definition and Usage

The disabled property sets or returns whether or not the button should be disabled.

Syntax

buttonObject.disabled=true|false

Example

<html>
<head>
<script type="text/javascript">
function disableButton()
{
document.getElementById("myButton").disabled=true
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!" id="myButton"
onClick="disableButton()" />
</form>
</body>
</html>


The id Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The id Property

Definition and Usage

The id property sets or returns the id of the button.

Note: In IE 4 this property is read-only.

Syntax

buttonObject.id=id

Example

<html>
<head>
<script type="text/javascript">
function alertId()
{
alert(document.getElementById("myButton").id)
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!" id="myButton"
onClick="alertId()" />
</form>
</body>
</html>


The type Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The type Property

Definition and Usage

The type property returns the type of the form element. For a Button object it will be "button".

Syntax

buttonObject.type

Example

<html>
<head>
<script type="text/javascript">
function alertType()
{
alert(document.getElementById("myButton").type)
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!" id="myButton"
onClick="alertType()" />
</form>
</body>
</html>


The value Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The value Property

Definition and Usage

The value property sets or returns the text that is displayed on the button.

Syntax

buttonObject.value=sometext

Example

<html>
<head>
<script type="text/javascript">
function alertValue()
{
alert(document.getElementById("myButton").value)
}
</script>
</head>
<body>
<form>
<input type="button" value="Click me!" id="myButton"
onClick="alertValue()" />
</form>
</body>
</html>


The checked Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The checked Property

Definition and Usage

The checked property sets or returns whether or not the checkbox should be checked.

Syntax

checkboxObject.checked=true|false

Example

<html>
<head>
<script type="text/javascript">
function check()
{
document.getElementById("myCheck").checked=true
}

function uncheck()
{
document.getElementById("myCheck").checked=false
}
</script>
</head>
<body>
<form>
<input type="checkbox" id="myCheck" />
<input type="button" onclick="check()"
value="Check Checkbox" />
<input type="button" onclick="uncheck()"
value="Uncheck Checkbox" />
</form>
</body>
</html>


The domain Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The domain Property

Definition and Usage

The domain property returns the document server's domain name.

Syntax

document.domain

Example

<html>
<body>
The domain name for this site is:
<script type="text/javascript">
document.write(document.domain)
</script>
</body>
</html>


The referrer Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The referrer Property

Definition and Usage

The referrer property returns the URL of the document that loaded the current document.

Syntax

document.referrer

Example

<html>
<body>
The referrer of this document is:
<script type="text/javascript">
document.write(document.referrer)
</script>
</body>
</html>


The title Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The title Property

Definition and Usage

The title property returns the title of the document (the text inside the HTML title element).

Syntax

document.title

Example

<html>
<head>
<title>MY TITLE</title>
</head>
<body>
The title of the document is:
<script type="text/javascript">
document.write(document.title)
</script>
</body>
</html>


The URL Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The URL Property

Definition and Usage

The URL property returns the URL of the current document.

Syntax

document.URL

Example

<html>
<body>
The URL of this document is:
<script type="text/javascript">
document.write(document.URL)
</script>
</body>
</html>


The action Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The action Property

Definition and Usage

The action property sets or returns the URL of where the input data will be submitted.

Syntax

formObject.action=URL

Example

<html>
<head>
<script type="text/javascript">
function changeAction()
{
var x=document.getElementById("myForm")
alert("Origional action: " + x.action)
x.action="default.asp"
alert("New action: " + x.action)
}
</script>
</head>
<body>
<form id="myForm" action="js_examples.asp">
<input type="button" onclick="changeAction()"
value="Change value of action attribute">
</form>
</body>
</html>


The method Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The method Property

Definition and Usage

The method property sets or returns how form data is submitted to the server ("get" or "post").

Syntax

formObject.method=get|post

Example

<html>
<head>
<script type="text/javascript">
function showMethod()
{
var x=document.getElementById("myForm")
alert(x.method)
}
</script>
</head>
<body>
<form id="myForm" method="post">
Name: <input type="text" size="20" value="Mickey Mouse">
<br /><br />
<input type="button" onclick="showMethod()" value="Show method">
</form>
</body>
</html>


The noResize Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The noResize Property

Definition and Usage

The noResize property sets or returns whether the frame can be resized.

Syntax

frameObject.noResize=true|false

Example

<html>
<head>
<script type="text/javascript">
function disableResize()
{
parent.document.getElementById("leftFrame").noResize=true
parent.document.getElementById("rightFrame").noResize=true
}
function enableResize()
{
parent.document.getElementById("leftFrame").noResize=false
parent.document.getElementById("rightFrame").noResize=false
}
</script>
</head>
<body bgcolor="#EFE7D6">
<form>
<input type="button" onclick="disableResize()" value="No resize">
<input type="button" onclick="enableResize()" value="Resize">
</form>
</body>
</html>


The scrolling Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The scrolling Property

Definition and Usage

The scrolling property sets or returns whether the frame can be scrolled.

Syntax

frameObject.scrolling=yes|no

Example

<html>
<head>
<script type="text/javascript">
function enableScrolling()
{
parent.document.getElementById("leftFrame").scrolling="yes"
parent.document.getElementById("rightFrame").scrolling="yes"
}
function disableScrolling()
{
parent.document.getElementById("leftFrame").scrolling="no"
parent.document.getElementById("rightFrame").scrolling="no"
}
</script>
</head>
<body bgcolor="#EFE7D6">
<form>
<input type="button" onclick="enableScrolling()"
value="Scroll bars">
<input type="button" onclick="disableScrolling()"
value="No scroll bars">
</form>
</body>
</html>


The src Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The src Property

Definition and Usage

The src property sets or returns the URL to be loaded by the frame.

Syntax

frameObject.src=URL

Example

<html>
<head>
<script type="text/javascript">
function newSrc()
{
parent.document.getElementById("lFrame").src="default.asp"
parent.document.getElementById("rFrame").src="http://google.com"
}
</script>
</head>
<body bgcolor="#EFE7D6">
<form>
<input type="button" onclick="newSrc()"
value="Change frame source">
</form>
</body>
</html>


The src Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The src Property

Definition and Usage

The src property sets or returns the URL to be loaded by the iframe.

Syntax

iframeObject.src=URL

Example

<html>
<head>
<script type="text/javascript">
function twoframes()
{
document.getElementById("frame1").src="frame_c.htm"
document.getElementById("frame2").src="frame_d.htm"
}
</script>
</head>
<body>
<iframe src="frame_a.htm" id="frame1"></iframe>
<iframe src="frame_b.htm" id="frame2"></iframe>
<br />
<form>
<input type="button" onclick="twoframes()"
value="Change URL of the two iframes">
</form>
</body>
</html>


The height Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The height Property

Definition and Usage

The height property sets or returns the value of the height attribute of the <img> tag in pixels.

Syntax

imageObject.height=number

Example

<html>
<head>
<script type="text/javascript">
function changeSize()
{
document.getElementById("compman").height="250"
document.getElementById("compman").width="300"
}
</script>
</head>
<body>
<img id="compman" src="compman.gif" width="107" height="98" />
<br /><br />
<input type="button" onclick="changeSize()"
value="Change size of image">
</body>
</html>


The src Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The src Property

Definition and Usage

The src property sets or returns the URL of the image.

Note: This property can be changed at any time. However, the new image is scaled to fit the height and width attributes of the original image.

Syntax

imageObject.src=URL

Example

<html>
<head>
<script type="text/javascript">
function changeSrc()
{
document.getElementById("myImage").src="hackanm.gif"
}
</script>
</head>
<body>
<img id="myImage" src="compman.gif" width="107" height="98" />
<br /><br />
<input type="button" onclick="changeSrc()" value="Change image">
</body>
</html>


The width Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The width Property

Definition and Usage

The width property sets or returns the value of the width attribute of the <img> tag in pixels.

Syntax

imageObject.width=number

Example

<html>
<head>
<script type="text/javascript">
function changeSize()
{
document.getElementById("compman").height="250"
document.getElementById("compman").width="300"
}
</script>
</head>
<body>
<img id="compman" src="compman.gif" width="107" height="98" />
<br /><br />
<input type="button" onclick="changeSize()"
value="Change size of image">
</body>
</html>


The hash Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The hash Property

Definition and Usage

The hash property sets or returns the part of the href property that follows the hash sign (#).

Syntax

location.hash


The appCodeName Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The appCodeName Property

Definition and Usage

The appCodeName property returns the code name of the browser.

Syntax

navigator.appCodeName

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>CodeName: ")
document.write(navigator.appCodeName + "</p>")
</script>
</body>
</html>


The appMinorVersion Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The appMinorVersion Property

Definition and Usage

The appMinorVersion property returns the minor version of the browser.

Syntax

navigator.appMinorVersion

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>MinorVersion: ")
document.write(navigator.appMinorVersion + "</p>")
</script>
</body>
</html>


The appName Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The appName Property

Definition and Usage

The appName property returns the name of the browser.

Syntax

navigator.appName

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>Name: ")
document.write(navigator.appName + "</p>")
</script>
</body>
</html>


The appVersion Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The appVersion Property

Definition and Usage

The appVersion property returns the platform and version of the browser.

Syntax

navigator.appVersion

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>Version: ")
document.write(navigator.appVersion + "</p>")
</script>
</body>
</html>


The browserLanguage Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The browserLanguage Property

Definition and Usage

The browserLanguage property returns the current browser language.

Syntax

navigator.browserLanguage

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>BrowserLanguage: ")
document.write(navigator.browserLanguage + "</p>")
</script>
</body>
</html>


The cookieEnabled Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The cookieEnabled Property

Definition and Usage

The cookieEnabled property returns a Boolean value that specifies whether cookies are enabled in the browser.

Syntax

navigator.cookieEnabled

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>CookieEnabled: ")
document.write(navigator.cookieEnabled + "</p>")
</script>
</body>
</html>


The cpuClass Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The cpuClass Property

Definition and Usage

The cpuClass property returns the CPU class of the browser's system.

Syntax

navigator.cpuClass

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>CPUClass: ")
document.write(navigator.cpuClass + "</p>")
</script>
</body>
</html>


The onLine Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The onLine Property

Definition and Usage

The onLine property returns a Boolean value that specifies whether the system is in offline mode.

Note: In IE 4+ the user can choose to work offline by selecting File/Work Offline in the browser. When Work Offline is selected, the system enters an offline state, and content is read from the cache.

Syntax

navigator.onLine

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>OnLine: ")
document.write(navigator.onLine + "</p>")
</script>
</body>
</html>


The platform Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The platform Property

Definition and Usage

The platform property returns the operating system platform.

Syntax

navigator.platform

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>Platform: ")
document.write(navigator.platform + "</p>")
</script>
</body>
</html>


The systemLanguage Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The systemLanguage Property

Definition and Usage

The systemLanguage property returns the default language used by the operating system.

Syntax

navigator.systemLanguage

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>SystemLanguage: ")
document.write(navigator.systemLanguage + "</p>")
</script>
</body>
</html>


The userAgent Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The userAgent Property

Definition and Usage

The userAgent property returns the value of the user-agent header sent by the client to the server.

Syntax

navigator.userAgent

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>UserAgent: ")
document.write(navigator.userAgent + "</p>")
</script>
</body>
</html>


The userLanguage Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The userLanguage Property

Definition and Usage

The userLanguage property returns the operating system's natural language settings.

Syntax

navigator.userLanguage

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>UserLanguage: ")
document.write(navigator.userLanguage + "</p>")
</script>
</body>
</html>


The form Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The form Property

Definition and Usage

The form property returns a reference to the form that contains the option object.

Syntax

optionObject.form

Example

<html>
<head>
<script type="text/javascript">
function showFormId()
{
alert(document.getElementById("mySelect").form.id)
}
</script>
</head>
<body>
<form id="myForm">
<select id="mySelect">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>
</select>
<input type="button" onclick="showFormId()"
value="Show the form's id">
</form>
</body>
</html>


The text Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The text Property

Definition and Usage

The text property sets or returns the text value for the <option> tag.

Syntax

optionObject.text=sometext

Example

<html>
<head>
<script type="text/javascript">
function getOption()
{
var x=document.getElementById("mySelect")
alert(x.options[x.selectedIndex].text)
}
</script>
</head>
<body>
<form>
Select your favorite fruit:
<select id="mySelect">
<option>Apple</option>
<option>Orange</option>
<option>Pineapple</option>
<option>Banana</option>
</select>
<br /><br />
<input type="button" onclick="getOption()"
value="Alert selected fruit">
</form>
</body>
</html>


The value Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The value Property

Definition and Usage

The value property sets or returns the value of the value attribute of the radio button.

Syntax

radioObject.value=sometext

Example

<html>
<head>
<script type="text/javascript">
function check(browser)
{
document.getElementById("answer").value=browser
}
</script>
</head>
<body>
<p>What's your favorite browser:</p>
<form>
<input type="radio" name="browser" onclick="check(this.value)"
value="Internet Explorer">Internet Explorer<br />
<input type="radio" name="browser" onclick="check(this.value)"
value="Firefox">Firefox<br />
<input type="radio" name="browser" onclick="check(this.value)"
value="Netscape">Netscape<br />
<input type="radio" name="browser" onclick="check(this.value)"
value="Opera">Opera<br />
<br />
Your favorite browser is: <input type="text" id="answer" size="20">
</form>
</body>
</html>


The availHeight Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The availHeight Property

Definition and Usage

The availHeight property returns the height of the client's display screen - excluding the Windows Taskbar.

Syntax

screen.availHeight

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>Available Height: ")
document.write(screen.availHeight + "</p>")
</script>
</body>
</html>


The availWidth Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The availWidth Property

Definition and Usage

The availWidth property returns the width of the client's display screen - excluding the Windows Taskbar.

Syntax

screen.availWidth

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>Available Width: ")
document.write(screen.availWidth + "</p>")
</script>
</body>
</html>


The bufferDepth Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The bufferDepth Property

Definition and Usage

The bufferDepth property sets or returns the bit depth of the color palette in the off-screen bitmap buffer.

Syntax

screen.bufferDepth=number

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>Buffer Depth: ")
document.write(screen.bufferDepth + "</p>")
</script>
</body>
</html>


The colorDepth Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The colorDepth Property

Definition and Usage

The colorDepth property returns the bit depth of the color palette on the destination device or buffer.

Syntax

screen.colorDepth

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>Color Depth: ")
document.write(screen.colorDepth + "</p>")
</script>
</body>
</html>


The height Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The height Property

Definition and Usage

The height property returns the height of the client's display screen.

Syntax

screen.height

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>Height: ")
document.write(screen.height + "</p>")
</script>
</body>
</html>


The width Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The width Property

Definition and Usage

The width property returns the width of the client's display screen.

Syntax

screen.width

Example

<html>
<body>
<script type="text/javascript">
document.write("<p>Width: ")
document.write(screen.width + "</p>")
</script>
</body>
</html>


The disabled Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The disabled Property

Definition and Usage

The disabled property sets or returns whether or not the drop-down list should be disabled.

Syntax

selectObject.disabled=true|false

Example

<html>
<head>
<script type="text/javascript">
function disable()
{
document.getElementById("mySelect").disabled=true
}
function enable()
{
document.getElementById("mySelect").disabled=false
}
</script>
</head>
<body>
<form>
<select id="mySelect">
<option>Apple</option>
<option>Pear</option>
<option>Banana</option>
<option>Orange</option>
</select>
<input type="button" onclick="disable()" value="Disable list">
<input type="button" onclick="enable()" value="Enable list">
</form>
</body>
</html>


The accessKey Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The accessKey Property

Definition and Usage

The accessKey property sets or returns the keyboard key to access a text field.

Note: Use Alt + accessKey to give focus to the elements with a specified access key.

Syntax

textObject.accessKey=accessKey

Example

<html>
<head>
<script type="text/javascript">
function access()
{
document.getElementById('myName').accessKey="n"
document.getElementById('myPwd').accessKey="p"
document.getElementById('myCheck').accessKey="c"
}
</script>
</head>
<body onload="access()">
<form>
Enter your name: <input id="myName" type="text" />
<br />
Enter your password: <input id="myPwd" type="password" />
<br /><br />
<input type="checkbox" id="myCheck" /> Remember password
</form>
</body>
</html>


The maxLength Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The maxLength Property

Definition and Usage

The maxLength property sets or returns the maximum number of characters in a text field.

Syntax

textObject.maxLength=number

Example

<html>
<head>
<script type="text/javascript">
function maxLen()
{
alert(document.getElementById("name").maxLength)
}
</script>
</head>
<body>
<form>
Enter your name:
<input type="text" id="name" value="Mickey Mouse"
size="20" maxlength="50" />
<br /><br />
<input type="button" onclick="maxLen()"
value="Check maxlength of input field" />
</form>
</body>
</html>


The tabIndex Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The tabIndex Property

Definition and Usage

The tabIndex property sets or returns the tab order for a text field.

Syntax

textObject.tabIndex=number

Example

<html>
<head>
<script type="text/javascript">
function checkTab(x)
{
alert(x.tabIndex)
}
</script>
</head>
<body>
<form id="myForm">
<input tabindex="1" onkeydown="checkTab(this)">
<input tabindex="2" onkeydown="checkTab(this)">
<input tabindex="3" onkeydown="checkTab(this)">
</form>
</body>
</html>


The value Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Document
DOM Event
DOM Form
DOM Frame
DOM Frameset
DOM History
DOM Iframe
DOM Image
DOM Input Button
DOM Input Checkbox
DOM Input File
DOM Input Hidden
DOM Input Password
DOM Input Radio
DOM Input Reset
DOM Input Submit
DOM Input Text
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Object
DOM Option
DOM Screen
DOM Select
DOM Style
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Textarea
DOM Window

The value Property

Definition and Usage

The value property sets or returns the value of the value attribute of the text field.

Syntax

textObject.value=sometext

Example

<html>
<head>
<script type="text/javascript">
function check(browser)
{
document.getElementById("answer").value=browser
}
</script>
</head>
<body>
<p>What's your favorite browser:</p>
<form>
<input type="radio" name="browser" onclick="check(this.value)"
value="Internet Explorer">Internet Explorer<br />
<input type="radio" name="browser" onclick="check(this.value)"
value="Firefox">Firefox<br />
<input type="radio" name="browser" onclick="check(this.value)"
value="Netscape">Netscape<br />
<input type="radio" name="browser" onclick="check(this.value)"
value="Opera">Opera<br />
<br />
Your favorite browser is: <input type="text" id="answer" size="20">
</form>
</body>
</html>


JavaScript Reference

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

JavaScript Reference

This section contains a complete reference of all the built-in JavaScript objects, along with their methods and properties.

This section also contains an event reference and a reference of the top-level properties and functions that can be used on all of the built-in JavaScript objects.

A reference to all of the HTML DOM objects are listed in the menu to the left.

JavaScript String Object

The String object is used to manipulate a stored piece of text.

For a complete reference of the properties and methods that can be used with the String object, go to our String object reference.

The reference contains a brief description and examples of use for each property and method!

JavaScript Date Object

The JavaScript Date object is used to work with dates and times.

For a complete reference of the properties and methods that can be used with the Date object, go to our Date object reference.

The reference contains a brief description and examples of use for each property and method!

JavaScript Array Object

The JavaScript Array object is used to store a set of values in a single variable name.

For a complete reference of the properties and methods that can be used with the Array object, go to our Array object reference.

The reference contains a brief description and examples of use for each property and method!

JavaScript Boolean Object

The JavaScript Boolean object is an object wrapper for a Boolean value.

For a complete reference of the properties and methods that can be used with the Boolean object, go to our Boolean object reference.

The reference contains a brief description and examples of use for each property and method!

JavaScript Math Object

The JavaScript Math object allows you to perform common mathematical tasks. It includes several mathematical constants and functions.

For a complete reference of the properties and methods that can be used with the Math object, go to our Math object reference.

The reference contains a brief description and examples of use for each property and method!

JavaScript Top-level Properties and Functions

The top-level properties and functions that can be used on all of the built-in JavaScript objects.

For a complete reference of the properties and functions that can be used with all the JavaScript objects, go to our Top-level reference.

The reference contains a brief description and examples of use for each property and function!

JavaScript Events

New to HTML 4.0 was the ability to let HTML events trigger actions in the browser, like starting a JavaScript when a user clicks on an HTML element.

For a complete reference of all the event attributes, go to our Event reference.

The reference contains a brief description and examples of use for each event!

HTML DOM Objects

In addition to the built-in JavaScript objects, you can also access and manipulate all of the HTML DOM objects with JavaScript.

The HTML DOM defines a standard set of objects for HTML, and a standard way to access and manipulate HTML documents.

For a complete reference of all the DOM objects, go to our DOM reference.


The abs() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The abs() method

Definition and Usage

The abs() method returns the absolute value of a number.

Syntax

Math.abs(x)

Parameter | Description
x | Required. Must be a numeric value

Example

In this example get the absolute values of positive and negative numbers:

<script type="text/javascript">
document.write(Math.abs(7.25) + "<br />")
document.write(Math.abs(-7.25) + "<br />")
document.write(Math.abs(7.25-10))
</script>

The output of the code above will be:

7.25
7.25
2.75


The acos() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The acos() method

Definition and Usage

The acos() method returns the arccosine of a number as a numeric value value between 0 and PI radians.

Syntax

Math.acos(x)

Parameter | Description
x | Required. Must be a numeric value in the range -1 to 1

Tips and Notes

Note: If the parameter x is outside the range -1 to 1, the browser will return NaN.

Note: -1 will return the value of PI.

Example

In this example we will get the arccosine of different numbers:

<script type="text/javascript">
document.write(Math.acos(0.64) + "<br />")
document.write(Math.acos(0) + "<br />")
document.write(Math.acos(-1) + "<br />")
document.write(Math.acos(1) + "<br />")
document.write(Math.acos(2))
</script>

The output of the code above will be:

0.8762980611683406
1.5707963267948965
3.141592653589793
0
NaN


The anchor() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The anchor() method

Definition and Usage

The anchor() method is used to create an HTML anchor.

Syntax

stringObject.anchor(anchorname)

Parameter | Description
anchorname | Required. Defines a name for the anchor

Example

In this example we will add an anchor to a text:

<script type="text/javascript">
var txt="Hello world!"
document.write(txt.anchor("myanchor"))
</script>

The code above could be written in plain HTML, like this:

<a name="myanchor">Hello world!</a>


The asin() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The asin() method

Definition and Usage

The asin() method returns the arcsine of a number as a numeric value between
-PI/2 and PI/2 radians.

Syntax

Math.asin(x)

Parameter | Description
x | Required. Must be a numeric value in the range -1 to 1

Tips and Notes

Note: If the parameter x is outside the range -1 to 1, the browser will return NaN.

Note: 1 will return the value of PI/2.

Example

In this example we will get the arcsine of different numbers:

<script type="text/javascript">
document.write(Math.asin(0.64) + "<br />")
document.write(Math.asin(0) + "<br />")
document.write(Math.asin(-1) + "<br />")
document.write(Math.asin(1) + "<br />")
document.write(Math.asin(2))
</script>

The output of the code above will be:

0.6944982656265559
0
-1.5707963267948965
1.5707963267948965
NaN


The atan() and atan2() methods

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The atan() and atan2() methods

Definition and Usage

The atan() method returns the arctangent of a number as a numeric value between -PI/2 and PI/2 radians.

The atan2() method returns the angle theta of an (x,y) point as a numeric value between -PI/2 and PI/2 radians.

Syntax

Math.atan(x)
Math.atan2(x,y)

Parameter | Description
x | Required. A number
y | Required. A number

Example 1 - atan()

The following example returns the arctangent of different numbers with the atan() method:

<script type="text/javascript">
document.write(Math.atan(0.50) + "<br />")
document.write(Math.atan(-0.50) + "<br />")
document.write(Math.atan(5) + "<br />")
document.write(Math.atan(10) + "<br />")
document.write(Math.atan(-5) + "<br />")
document.write(Math.atan(-10))
</script>

The output of the code above will be:

0.4636476090008061
-0.4636476090008061
1.373400766945016
1.4711276743037347
-1.373400766945016
-1.4711276743037347

Example 2 - atan2()

The following example returns the angle theta of different (x,y) points with the atan2() method:

<script type="text/javascript">
document.write(Math.atan2(0.50,0.50) + "<br />")
document.write(Math.atan2(-0.50,-0.50) + "<br />")
document.write(Math.atan2(5,5) + "<br />")
document.write(Math.atan2(10,20) + "<br />")
document.write(Math.atan2(-5,-5) + "<br />")
document.write(Math.atan2(-10,10))
</script>

The output of the code above will be:

0.7853981633974483
-2.356194490192345
0.7853981633974483
0.4636476090008061
-2.356194490192345
-0.7853981633974483


The big() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The big() method

Definition and Usage

The big() method is used to display a string in a big font.

Syntax

stringObject.big()

Example

In this example "Hello world!" will be displayed in a big font:

<script type="text/javascript">
var str="Hello world!"
document.write(str.big())
</script>


The blink() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The blink() method

Definition and Usage

The blink() method is used to display a blinking string.

Syntax

stringObject.blink()

Tips and Notes

Note: This method does not work in Internet Explorer.

Example

In this example "Hello world!" will be displayed as blinking text:

<script type="text/javascript">
var str="Hello world!"
document.write(str.blink())
</script>


The bold() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The bold() method

Definition and Usage

The bold() method is used to display a string in bold.

Syntax

stringObject.bold()

Example

In this example "Hello world!" will be displayed in bold:

<script type="text/javascript">
var str="Hello world!"
document.write(str.bold())
</script>


The ceil() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The ceil() method

Definition and Usage

The ceil() method returns the value of a number rounded UPWARDS to the nearest integer.

Syntax

Math.ceil(x)

Parameter | Description
x | Required. A number

Example

In the following example we will use the ceil() method on different numbers:

<script type="text/javascript">
document.write(Math.ceil(0.60) + "<br />")
document.write(Math.ceil(0.40) + "<br />")
document.write(Math.ceil(5) + "<br />")
document.write(Math.ceil(5.1) + "<br />")
document.write(Math.ceil(-5.1) + "<br />")
document.write(Math.ceil(-5.9))
</script>

The output of the code above will be:

1
1
5
6
-5
-5


The charAt() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The charAt() method

Definition and Usage

The charAt() method returns the character at a specified position.

Syntax

stringObject.charAt(index)

Parameter | Description
index | Required. A number representing a position in the string

Tips and Notes

Note: The first character in the string is at position 0.

Example

In the string "Hello world!", we will return the character at position 1:

<script type="text/javascript">
var str="Hello world!"
document.write(str.charAt(1))
</script>

The output of the code above will be:

e


The charCodeAt() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The charCodeAt() method

Definition and Usage

The charCodeAt() method returns the Unicode of the character at a specified position.

Syntax

stringObject.charCodeAt(index)

Parameter | Description
index | Required. A number representing a position in the string

Tips and Notes

Note: The first character in the string is at position 0.

Example

In the string "Hello world!", we will return the Unicode of the character at position 1:

<script type="text/javascript">
var str="Hello world!"
document.write(str.charCodeAt(1))
</script>

The output of the code above will be:

101


The concat() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The concat() method

Definition and Usage

The concat() method is used to join two or more arrays.

This method does not change the existing arrays, it only returns a copy of the joined arrays.

Syntax

arrayObject.concat(arrayX,arrayX,......,arrayX)

Parameter | Description
arrayX | Required. One or more array objects to be joined to an array

Example 1

Here we create two arrays and show them as one using concat():

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Tove"
arr[2] = "Hege"
var arr2 = new Array(3)
arr2[0] = "John"
arr2[1] = "Andy"
arr2[2] = "Wendy"
document.write(arr.concat(arr2))
</script>

The output of the code above will be:

Jani,Tove,Hege,John,Andy,Wendy

Example 2

Here we create three arrays and show them as one using concat():

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Tove"
arr[2] = "Hege"
var arr2 = new Array(3)
arr2[0] = "John"
arr2[1] = "Andy"
arr2[2] = "Wendy"
var arr3 = new Array(2)
arr3[0] = "Stale"
arr3[1] = "Borge"
document.write(arr.concat(arr2,arr3))
</script>

The output of the code above will be:

Jani,Tove,Hege,John,Andy,Wendy,Stale,Borge


The concat() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The concat() method

Definition and Usage

The concat() method is used to join two or more strings.

Syntax

stringObject.concat(stringX,stringX,...,stringX)

Parameter | Description
stringX | Required. One or more string objects to be joined to a string

Example

In the following example we will create two strings and show them as one using concat():

<script type="text/javascript">
var str1="Hello "
var str2="world!"
document.write(str1.concat(str2))
</script>

The output of the code above will be:

Hello world!


The constructor property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The constructor Property

Definition and Usage

The constructor property is a reference to the function that created an object.

Syntax

object.constructor

Example 1

In this example we will show how to use the constructor property:

<script type="text/javascript">
var test=new Array()
if (test.constructor==Array)
{document.write("This is an Array")}
if (test.constructor==Boolean)
{document.write("This is a Boolean")}
if (test.constructor==Date)
{document.write("This is a Date")}
if (test.constructor==String)
{document.write("This is a String")}
</script>

The output of the code above will be:

This is an Array

Example 2

In this example we will show how to use the constructor property:

<script type="text/javascript">
function employee(name,jobtitle,born)
{
this.name=name
this.jobtitle=jobtitle
this.born=born
}
var fred=new employee("Fred Flintstone","Caveman",1970)
document.write(fred.constructor)
</script>

The output of the code above will be:

function employee(name, jobtitle, born)
{this.name = name; this.jobtitle = jobtitle; this.born = born;}


The constructor property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The constructor Property

Definition and Usage

The constructor property is a reference to the function that created an object.

Syntax

object.constructor

Example 1

In this example we will show how to use the constructor property:

<script type="text/javascript">
var test=new Boolean()
if (test.constructor==Array)
{document.write("This is an Array")}
if (test.constructor==Boolean)
{document.write("This is a Boolean")}
if (test.constructor==Date)
{document.write("This is a Date")}
if (test.constructor==String)
{document.write("This is a String")}
</script>

The output of the code above will be:

This is a Boolean

Example 2

In this example we will show how to use the constructor property:

<script type="text/javascript">
function employee(name,jobtitle,born)
{
this.name=name
this.jobtitle=jobtitle
this.born=born
}
var fred=new employee("Fred Flintstone","Caveman",1970)
document.write(fred.constructor)
</script>

The output of the code above will be:

function employee(name, jobtitle, born)
{this.name = name; this.jobtitle = jobtitle; this.born = born;}


The constructor property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The constructor Property

Definition and Usage

The constructor property is a reference to the function that created an object.

Syntax

object.constructor

Example 1

In this example we will show how to use the constructor property:

<script type="text/javascript">
var test=new Date()
if (test.constructor==Array)
{document.write("This is an Array")}
if (test.constructor==Boolean)
{document.write("This is a Boolean")}
if (test.constructor==Date)
{document.write("This is a Date")}
if (test.constructor==String)
{document.write("This is a String")}
</script>

The output of the code above will be:

This is a Date

Example 2

In this example we will show how to use the constructor property:

<script type="text/javascript">
function employee(name,jobtitle,born)
{
this.name=name
this.jobtitle=jobtitle
this.born=born
}
var fred=new employee("Fred Flintstone","Caveman",1970)
document.write(fred.constructor)
</script>

The output of the code above will be:

function employee(name, jobtitle, born)
{this.name = name; this.jobtitle = jobtitle; this.born = born;}


The constructor property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The constructor Property

Definition and Usage

The constructor property is a reference to the function that created an object.

Syntax

object.constructor

Example 1

In this example we will show how to use the constructor property:

<script type="text/javascript">
var test=new String()
if (test.constructor==Array)
{document.write("This is an Array")}
if (test.constructor==Boolean)
{document.write("This is a Boolean")}
if (test.constructor==Date)
{document.write("This is a Date")}
if (test.constructor==String)
{document.write("This is a String")}
</script>

The output of the code above will be:

This is a String

Example 2

In this example we will show how to use the constructor property:

<script type="text/javascript">
function employee(name,jobtitle,born)
{
this.name=name
this.jobtitle=jobtitle
this.born=born
}
var fred=new employee("Fred Flintstone","Caveman",1970)
document.write(fred.constructor)
</script>

The output of the code above will be:

function employee(name, jobtitle, born)
{this.name = name; this.jobtitle = jobtitle; this.born = born;}


The cos() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The cos() method

Definition and Usage

The cos() method returns the cosine of a number.

Syntax

Math.cos(x)

Parameter | Description
x | Required. A number

Tips and Notes

Note: The cos() method returns a numeric value between -1 and 1, which represents the cosine of the angle.

Example

In the following example we will return the cosine of different numbers:

<script type="text/javascript">
document.write(Math.cos(3) + "<br />")
document.write(Math.cos(-3) + "<br />")
document.write(Math.cos(0) + "<br />")
document.write(Math.cos(Math.PI) + "<br />")
document.write(Math.cos(2*Math.PI))
</script>

The output of the code above will be:

-0.9899924966004454
-0.9899924966004454
1
-0.8390715290764524
-1
1


The Date() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The Date() method

Definition and Usage

The Date() method returns today's date and time.

Syntax

Date()

Example

In this example we will print today's date and time:

<script type="text/javascript">
document.write(Date())
</script>

The output of the code above will be:

Mon Oct 24 2005 08:31:12 GMT-0500 (Central Daylight Time)


The decodeURI() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The decodeURI() Function

Definition and Usage

The decodeURI() function decodes a URI encoded with the encodeURI() function.

Syntax

decodeURI(URIstring)

Parameter | Description
URIstring | Required. The URI to be decoded

Example

In this example we use decodeURI() to decode a URI after encoding it:

<script type="text/javascript">
var test1="http://www.w3schools.com/My first/"
document.write(encodeURI(test1)+ "<br />")
document.write(decodeURI(test1))
</script>

The output of the code above will be:

http://www.w3schools.com/My%20first/
http://www.w3schools.com/My first/


The decodeURIComponent() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The decodeURIComponent() Function

Definition and Usage

The decodeURIComponent() function decodes a URI encoded with the encodeURIComponent() function.

Syntax

decodeURIComponent(URIstring)

Parameter | Description
URIstring | Required. The URI to be decoded

Example

In this example we use decodeURIComponent() to decode a URI after encoding it:

<script type="text/javascript">
var test1="http://www.w3schools.com/My first/"
document.write(encodeURIComponent(test1)+ "<br />")
document.write(decodeURIComponent(test1))
</script>

The output of the code above will be:

http%3A%2F%2Fwww.w3schools.com%2FMy%20first%2F
http://www.w3schools.com/My first/


The encodeURI() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The encodeURI() Function

Definition and Usage

The encodeURI() function encodes a string as a URI.

Syntax

encodeURI(URIstring)

Parameter | Description
URIstring | Required. The URI to be encoded

Tips and Notes

Note: The encodeURI() function encodes special characters, with the exception of:
, / ? : @ & = + $ #. Use the encodeURIComponent() function to encode these characters.

Tip: Use the decodeURI() function to decode URIs encoded with encodeURI().

Example

In this example we use encodeURI() to encode URIs:

<script type="text/javascript">
document.write(encodeURI("http://www.w3schools.com")+ "<br />")
document.write(encodeURI("http://www.w3schools.com/My first/"))
document.write(encodeURI(",/?:@&=+$#"))
</script>

The output of the code above will be:

http://www.w3schools.com
http://www.w3schools.com/My%20first/
,/?:@&=+$#


The encodeURIComponent() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The encodeURIComponent() Function

Definition and Usage

The encodeURI() function encodes a string as a component of a URI.

Syntax

encodeURIComponent(URIstring)

Parameter | Description
URIstring | Required. The URI to be encoded

Tips and Notes

Tip: Use the decodeURIComponent() function to decode URIs encoded with encodeURIComponent().

Example

In this example we use encodeURIComponent() to encode URIs:

<script type="text/javascript">
document.write(encodeURIComponent("http://www.w3schools.com"))
document.write("<br />")
document.write(encodeURIComponent("http://www.w3schools.com/p 1/"))
document.write("<br />")
document.write(encodeURIComponent(",/?:@&=+$#"))
</script>

The output of the code above will be:

http%3A%2F%2Fwww.w3schools.com
http%3A%2F%2Fwww.w3schools.com%2Fp%201%2F
%2C%2F%3F%3A%40%26%3D%2B%24%23


The escape() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The escape() Function

Definition and Usage

The escape() function encodes a string, so it can be read on all computers.

Syntax

escape(string)

Parameter | Description
string | Required. The string to be encoded

Tips and Notes

Note: The escape() function encodes special characters, with the exception of:
* @ - _ + . /

Tip: Use the unescape() function to decode strings encoded with escape().

Note: The escape() and unescape() functions should not be used to encode or decode URIs. Use encodeURI() and decodeURI() functions instead!

Example

In this example we use escape() to encode strings:

<script type="text/javascript">
document.write(escape("Visit W3Schools!") + "<br />")
document.write(escape("?!=()#%&"))
</script>

The output of the code above will be:

Visit%20W3Schools%21
%3F%21%3D%28%29%23%25%26


The eval() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The eval() Function

Definition and Usage

The eval() function evaluates a string and executes it as if it was script code.

Syntax

eval(string)

Parameter | Description
string | Required. The string to be evaluated

Example

In this example we use eval() on some strings and see what it returns:

<script type="text/javascript">
eval("x=10;y=20;document.write(x*y)")
document.write("<br />")
document.write(eval("2+2"))
document.write("<br />")
var x=10
document.write(eval(x+17))
document.write("<br />")
</script>

The output of the code above will be:

200
4
27


JavaScript Event Reference

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

JavaScript Event Reference

Events are normally used in combination with functions, and the function will not be executed before the event occurs!

Event Handlers

New to HTML 4.0 was the ability to let HTML events trigger actions in the browser, like starting a JavaScript when a user clicks on an HTML element. Below is a list of the attributes that can be inserted into HTML tags to define event actions.

FF: Firefox, N: Netscape, IE: Internet Explorer

Attribute | The event occurs when... | FF | N | IE
onabort | Loading of an image is interrupted | 1 | 3 | 4
onblur | An element loses focus | 1 | 2 | 3
onchange | The content of a field changes | 1 | 2 | 3
onclick | Mouse clicks an object | 1 | 2 | 3
ondblclick | Mouse double-clicks an object | 1 | 4 | 4
onerror | An error occurs when loading a document or an image | 1 | 3 | 4
onfocus | An element gets focus | 1 | 2 | 3
onkeydown | A keyboard key is pressed | 1 | 4 | 3
onkeypress | A keyboard key is pressed or held down | 1 | 4 | 3
onkeyup | A keyboard key is released | 1 | 4 | 3
onload | A page or an image is finished loading | 1 | 2 | 3
onmousedown | A mouse button is pressed | 1 | 4 | 4
onmousemove | The mouse is moved | 1 | 6 | 3
onmouseout | The mouse is moved off an element | 1 | 4 | 4
onmouseover | The mouse is moved over an element | 1 | 2 | 3
onmouseup | A mouse button is released | 1 | 4 | 4
onreset | The reset button is clicked | 1 | 3 | 4
onresize | A window or frame is resized | 1 | 4 | 4
onselect | Text is selected | 1 | 2 | 3
onsubmit | The submit button is clicked | 1 | 2 | 3
onunload | The user exits the page | 1 | 2 | 3


The exp() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The exp() method

Definition and Usage

The exp() returns the value of Ex, where E is Euler's constant (approximately 2.7183) and x is the number passed to it.

Syntax

Math.exp(x)

Parameter | Description
x | Required. A number

Tips and Notes

Tip: E is the Euler's constant, which is the base of natural logarithms (approximately 2.7183).

Example

In the following example we will use the exp() method on different numbers:

<script type="text/javascript">
document.write(Math.exp(1) + "<br />")
document.write(Math.exp(-1) + "<br />")
document.write(Math.exp(5) + "<br />")
document.write(Math.exp(10) + "<br />")
</script>

The output of the code above will be:

2.718281828459045
0.36787944117144233
148.4131591025766
22026.465794806718


The fixed() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The fixed() method

Definition and Usage

The fixed() method is used to display a string as teletype text.

Syntax

stringObject.fixed()

Example

In this example "Hello world!" will be displayed as teletype text:

<script type="text/javascript">
var str="Hello world!"
document.write(str.fixed())
</script>


The floor() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The floor() method

Definition and Usage

The floor() method returns the value of a number rounded DOWNWARDS to the nearest integer.

Syntax

Math.floor(x)

Parameter | Description
x | Required. A number

Example

In this example we will use the floor() method on different numbers:

<script type="text/javascript">
document.write(Math.floor(0.60) + "<br />")
document.write(Math.floor(0.40) + "<br />")
document.write(Math.floor(5) + "<br />")
document.write(Math.floor(5.1) + "<br />")
document.write(Math.floor(-5.1) + "<br />")
document.write(Math.floor(-5.9))
</script>

The output of the code above will be:

0
0
5
5
-6
-6


The fontcolor() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The fontcolor() method

Definition and Usage

The fontcolor() method is used to display a string in a specified color.

Syntax

stringObject.fontcolor(color)

Parameter | Description
color | Required. Specifies a font-color for the string. The value can be a color name (red), an RGB value (rgb(255,0,0)), or a hex number (#FF0000)

Example

In this example "Hello world!" will be displayed in red:

<script type="text/javascript">
var str="Hello world!"
document.write(str.fontcolor("Red"))
</script>


The fontsize() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The fontsize() method

Definition and Usage

The fontsize() method is used to display a string in a specified size.

Syntax

stringObject.fontsize(size)

Parameter | Description
size | Required. A number that specifies the font size

Tips and Notes

Note: The size parameter must be a number from 1 to 7.

Example

In this example "Hello world!" will be displayed in a large font-size:

<script type="text/javascript">
var str="Hello world!"
document.write(str.fontsize(7))
</script>


The fromCharCode() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The fromCharCode() method

Definition and Usage

The fromCharCode() takes the specified Unicode values and returns a string.

Syntax

String.fromCharCode(numX,numX,...,numX)

Parameter | Description
numX | Required. One or more Unicode values

Tips and Notes

Note: This method is a static method of String - it is not used as a method of a String object that you have created. The syntax is always String.fromCharCode() and not myStringObject.fromCharCode().

Example

In this example we will write "HELLO" and "ABC" from Unicode:

<script type="text/javascript">
document.write(String.fromCharCode(72,69,76,76,79))
document.write("<br />")
document.write(String.fromCharCode(65,66,67))
</script>

The output of the code above will be:

HELLO
ABC


The getDate() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getDate() method

Definition and Usage

The getDate() method returns the day of the month.

Syntax

dateObject.getDate()

Tips and Notes

Note: The value returned by getDate() is a number between 1 and 31.

Note: This method is always used in conjunction with a Date object.

Example

In this example we print the day of the current month:

<script type="text/javascript">
var d = new Date()
document.write(d.getDate())
</script>

The output of the code above will be:

24

Example 2

Here we define a variable with a specific date and then print the day of the month in the variable:

<script type="text/javascript">
var birthday = new Date("July 21, 1983 01:15:00")
document.write(birthday.getDate())
</script>

The output of the code above will be:

21


The getDay() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getDay() method

Definition and Usage

The getDay() method returns a number that represents the day of the week.

Syntax

dateObject.getDay()

Tips and Notes

Note: The value returned by getDay() is a number between 0 and 6. Sunday is 0, Monday is 1 and so on.

Note: This method is always used in conjunction with a Date object.

Example

In this example we get the current day (as a number) of the week:

<script type="text/javascript">
var d=new Date()
document.write(d.getDay())
</script>

The output of the code above will be:

1

Example 2

Now we will create an array to get our example to write a weekday, and not just a number:

<script type="text/javascript">
var d=new Date()
var weekday=new Array(7)
weekday[0]="Sunday"
weekday[1]="Monday"
weekday[2]="Tuesday"
weekday[3]="Wednesday"
weekday[4]="Thursday"
weekday[5]="Friday"
weekday[6]="Saturday"
document.write("Today it is " + weekday[d.getDay()])
</script>

The output of the code above will be:

Today it is Monday


The getFullYear() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getFullYear() method

Definition and Usage

The getFullYear() method returns a four-digit number that represents a year.

Syntax

dateObject.getFullYear()

Tips and Notes

Note: This method is always used in conjunction with a Date object.

Example

In this example we get the current year and print it:

<script type="text/javascript">
var d = new Date()
document.write(d.getFullYear())
</script>

The output of the code above will be:

2005

Example 2

Here we will extract the year out of the specific date:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write("I was born in " + born.getFullYear())
</script>

The output of the code above will be:

I was born in 1983


The getHours() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getHours() method

Definition and Usage

The getHours() method returns the hour of a time.

Syntax

dateObject.getHours()

Tips and Notes

Note: The value returned by getHours() is a two digit number. However, the return value is not always two digits, if the value is less than 10 it only returns one digit.

Note: This method is always used in conjunction with a Date object.

Example

In this example we get the hour of the current time:

<script type="text/javascript">
var d = new Date()
document.write(d.getHours())
</script>

The output of the code above will be:

8

Example 2

Here we will extract the hour from the specific date and time:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.getHours())
</script>

The output of the code above will be:

1


The getMilliseconds() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getMilliseconds() method

Definition and Usage

The getMilliseconds() method returns the milliseconds of a time.

Syntax

dateObject.getMilliseconds()

Tips and Notes

Note: The value returned by getMilliseconds() is a three digit number. However, the return value is not always three digits, if the value is less than 100 it only returns two digits, and if the value is less than 10 it only returns one digit.

Note: This method is always used in conjunction with a Date object.

Example

In this example we get the milliseconds of the current time:

<script type="text/javascript">
var d = new Date()
document.write(d.getMilliseconds())
</script>

The output of the code above will be:

97

Example 2

Here we will extract the milliseconds from the specific date and time:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.getMilliseconds())
</script>

The output of the code above will be:

0

Note: The code above will set the milliseconds to 0, since no milliseconds was defined in the date.


The getMinutes() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getMinutes() method

Definition and Usage

The getMinutes() method returns the minutes of a time.

Syntax

dateObject.getMinutes()

Tips and Notes

Note: The value returned by getMinutes() is a two digit number. However, the return value is not always two digits, if the value is less than 10 it only returns one digit.

Note: This method is always used in conjunction with a Date object.

Example

In this example we get the minutes of the current time:

<script type="text/javascript">
var d = new Date()
document.write(d.getMinutes())
</script>

The output of the code above will be:

39

Example 2

Here we will extract the minutes from the specific date and time:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.getMinutes())
</script>

The output of the code above will be:

15


The getMonth() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getMonth() method

Definition and Usage

The getMonth() method returns the month, as a number.

Syntax

dateObject.getMonth()

Tips and Notes

Note: The value returned by getMonth() is a number between 0 and 11. January is 0, February is 1 and so on.

Note: This method is always used in conjunction with a Date object.

Example

In this example we get the current month and print it:

<script type="text/javascript">
var d=new Date()
document.write(d.getMonth())
</script>

The output of the code above will be:

9

Example 2

Now we will create an array to get our example to write the name of the month, and not just a number:

<script type="text/javascript">
var d=new Date()
var month=new Array(12)
month[0]="January"
month[1]="February"
month[2]="March"
month[3]="April"
month[4]="May"
month[5]="June"
month[6]="July"
month[7]="August"
month[8]="September"
month[9]="October"
month[10]="November"
month[11]="December"
document.write("The month is " + month[d.getMonth()])
</script>

The output of the code above will be:

The month is October


The getSeconds() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getSeconds() method

Definition and Usage

The getSeconds() method returns the seconds of a time.

Syntax

dateObject.getSeconds()

Tips and Notes

Note: The value returned by getSeconds() is a two digit number. However, the return value is not always two digits, if the value is less than 10 it only returns one digit.

Note: This method is always used in conjunction with a Date object.

Example

In this example we get the seconds of the current time:

<script type="text/javascript">
var d = new Date()
document.write(d.getSeconds())
</script>

The output of the code above will be:

46

Example 2

Here we will extract the seconds from the specific date and time:

<script type="text/javascript">
var Birthday = new Date("July 21, 1983 01:15:00")
document.write(Birthday.getSeconds())
</script>

The output of the code above will be:

0


The getTime() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getTime() method

Definition and Usage

The getTime() method returns the number of milliseconds since midnight of January 1, 1970.

Syntax

dateObject.getTime()

Tips and Notes

Note: This method is always used in conjunction with a Date object.

Example

In this example we will get how many milliseconds since 1970/01/01 and print it:

<script type="text/javascript">
var d = new Date()
document.write(d.getTime() + " milliseconds since 1970/01/01")
</script>

The output of the code above will be:

1130161352756 milliseconds since 1970/01/01

Example 2

In the following example we will calculate the number of years since 1970/01/01:

<script type="text/javascript">
var minutes = 1000*60
var hours = minutes*60
var days = hours*24
var years = days*365
var d = new Date()
var t = d.getTime()
var y = t/years
document.write("It's been: " + y + " years since 1970/01/01!")
</script>

The output of the code above will be:

It's been: 35.83718140493404 years since 1970/01/01!


The getTimezoneOffset() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getTimezoneOffset() method

Definition and Usage

The getTimezoneOffset() method returns the difference in minutes between local time and Greenwich Mean Time (GMT).

Syntax

dateObject.getTimezoneOffset()

Tips and Notes

Note: The returned value of this method is not a constant, because of the practice of using Daylight Saving Time.

Note: This method is always used in conjunction with a Date object.

Example

In the following example we get the difference in minutes between local time and Greenwich Mean Time (GMT):

<script type="text/javascript">
var d = new Date()
document.write(d.getTimezoneOffset())
</script>

The output of the code above will be:

300

Example 2

Now we will convert the example above into GMT +/- hours:

<script type="text/javascript">
var d = new Date()
var gmtHours = d.getTimezoneOffset()/60
document.write("The local time zone is: GMT " + gmtHours)
</script>

The output of the code above will be:

The local time zone is: GMT -2


The getUTCDate() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getUTCDate() method

Definition and Usage

The getUTCDate() method returns the day of the month according to the Universal Coordinated Time (UTC).

Syntax

dateObject.getUTCDate()

Tips and Notes

Note: The value returned by getUTCDate() is a number between 1 and 31.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we print the current day of the month according to UTC:

<script type="text/javascript">
var d = new Date()
document.write(d.getUTCDate())
</script>

The output of the code above will be:

24

Example 2

Here we define a variable with a specific date and then print the day of the month in the variable, according to UTC:

<script type="text/javascript">
var birthday = new Date("July 21, 1983 01:15:00")
document.write(birthday.getUTCDate())
</script>

The output of the code above will be:

21


The getUTCDay() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getUTCDay() method

Definition and Usage

The getUTCDay() method returns a number that represents the day of the week according to the Universal Coordinated Time (UTC).

Syntax

dateObject.getUTCDay()

Tips and Notes

Note: The value returned by getUTCDay() is a number between 0 and 6. Sunday is 0, Monday is 1 and so on.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we get the current UTC day (as a number) of the week:

<script type="text/javascript">
var d=new Date()
document.write(d.getUTCDay())
</script>

The output of the code above will be:

1

Example 2

Now we will create an array to get our example above to write a weekday, and not just a number:

<script type="text/javascript">
var d=new Date()
var weekday=new Array(7)
weekday[0]="Sunday"
weekday[1]="Monday"
weekday[2]="Tuesday"
weekday[3]="Wednesday"
weekday[4]="Thursday"
weekday[5]="Friday"
weekday[6]="Saturday"
document.write("Today it is " + weekday[d.getUTCDay()])
</script>

The output of the code above will be:

Today it is Monday


The getUTCFullYear() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getUTCFullYear() method

Definition and Usage

The getUTCFullYear() method returns a four-digit number that represents a year according to the Universal Coordinated Time (UTC).

Syntax

dateObject.getUTCFullYear()

Tips and Notes

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we get the current year and print it:

<script type="text/javascript">
var d = new Date()
document.write(d.getUTCFullYear())
</script>

The output of the code above will be:

2005

Example 2

Here we will extract the year out of the specific date:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write("I was born in " + born.getUTCFullYear())
</script>

The output of the code above will be:

I was born in 1983


The getUTCHours() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getUTCHours() method

Definition and Usage

The getUTCHours() method returns the hour of a time according to the Universal Coordinated Time (UTC).

Syntax

dateObject.getUTCHours()

Tips and Notes

Note: The value returned by getUTCHours() is a two digit number. However, the return value is not always two digits, if the value is less than 10 it only returns one digit.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we get the UTC hour of the current time:

<script type="text/javascript">
var d = new Date()
document.write(d.getUTCHours())
</script>

The output of the code above will be:

13

Example 2

Here we will extract the UTC hour from the specific date and time:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.getUTCHours())
</script>

The output of the code above will be:

23


The getUTCMilliseconds() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getUTCMilliseconds() method

Definition and Usage

The getUTCMilliseconds() method returns the milliseconds of a time according to the Universal Coordinated Time (UTC).

Syntax

dateObject.getUTCMilliseconds()

Tips and Notes

Note: The value returned by getUTCMilliseconds() is a three digit number. However, the return value is not always three digits, if the value is less than 100 it only returns two digits, and if the value is less than 10 it only returns one digit.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we get the UTC milliseconds of the current time:

<script type="text/javascript">
var d = new Date()
document.write(d.getUTCMilliseconds())
</script>

The output of the code above will be:

532

Example 2

Here we will extract the UTC milliseconds from the specific date and time:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.getUTCMilliseconds())
</script>

The output of the code above will be:

0

Note: The code above will set the milliseconds to 0, since no milliseconds was defined in the date.


The getUTCMinutes() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getUTCMinutes() method

Definition and Usage

The getUTCMinutes() method returns the minutes of a time according to the Universal Coordinated Time (UTC).

Syntax

dateObject.getUTCMinutes()

Tips and Notes

Note: The value returned by getUTCMinutes() is a two digit number. However, the return value is not always two digits, if the value is less than 10 it only returns one digit.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we get the UTC minutes of the current time:

<script type="text/javascript">
var d = new Date()
document.write(d.getUTCMinutes())
</script>

The output of the code above will be:

48

Example 2

Here we will extract the UTC minutes from the specific date and time:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.getUTCMinutes())
</script>

The output of the code above will be:

15


The getUTCMonth() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getUTCMonth() method

Definition and Usage

The getUTCMonth() method returns a number that represents a month according to the Universal Coordinated Time (UTC).

Syntax

dateObject.getUTCMonth()

Tips and Notes

Note: The value returned by getUTCMonth() is a number between 0 and 11. January is 0, February is 1 and so on.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we get the current month and print it:

<script type="text/javascript">
var d=new Date()
document.write(d.getUTCMonth())
</script>

The output of the code above will be:

9

Example 2

Now we will create an array to get our example to write the name of the month, and not just a number:

<script type="text/javascript">
var d=new Date()
var month=new Array(12)
month[0]="January"
month[1]="February"
month[2]="March"
month[3]="April"
month[4]="May"
month[5]="June"
month[6]="July"
month[7]="August"
month[8]="September"
month[9]="October"
month[10]="November"
month[11]="December"
document.write("The month is " + month[d.getUTCMonth()])
</script>

The output of the code above will be:

The month is October


The getUTCSeconds() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getUTCSeconds() method

Definition and Usage

The getUTCSeconds() method returns the seconds of a time according to the Universal Coordinated Time (UTC).

Syntax

dateObject.getUTCSeconds()

Tips and Notes

Note: The value returned by getUTCSeconds() is a two digit number. However, the return value is not always two digits, if the value is less than 10 it only returns one digit.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we get the UTC seconds of the current time:

<script type="text/javascript">
var d = new Date()
document.write(d.getUTCSeconds())
</script>

The output of the code above will be:

46

Example 2

Here we will extract the UTC seconds from the specific date and time:

<script type="text/javascript">
var Birthday = new Date("July 21, 1983 01:15:00")
document.write(Birthday.getUTCSeconds())
</script>

The output of the code above will be:

0


The getYear() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The getYear() method

Definition and Usage

The getYear() method returns the year, as a two-digit OR a four-digit number.

Syntax

dateObject.getYear()

Tips and Notes

Note: The value returned by getYear() is not always 4 numbers! For years between 1900 and 1999 the getYear() method returns only two digits. For years before 1900 and after 1999 it returns four digits!

Note: This method is always used in conjunction with a Date object.

Important: The getYear() method should no longer be used. Use the getFullYear() method instead!!

Example

In this example we get the current year and print it:

<script type="text/javascript">

var d = new Date()
document.write(d.getYear())

</script>

The output of the code above will be:

105

Example 2

Here we will extract the year out of the specific date:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write("I was born in " + born.getYear())
</script>

The output of the code above will be:

I was born in 83


The indexOf() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The indexOf() method

Definition and Usage

The indexOf() method returns the position of the first occurrence of a specified string value in a string.

Syntax

stringObject.indexOf(searchvalue,fromindex)

Parameter | Description
searchvalue | Required. Specifies a string value to search for
fromindex | Optional. Specifies where to start the search

Tips and Notes

Note: The indexOf() method is case sensitive!

Note: This method returns -1 if the string value to search for never occurs.

Example

In this example we will do different searches within a "Hello world!" string:

<script type="text/javascript">
var str="Hello world!"
document.write(str.indexOf("Hello") + "<br />")
document.write(str.indexOf("World") + "<br />")
document.write(str.indexOf("world"))
</script>

The output of the code above will be:

0
-1
6


The infinity Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The Infinity Property

Definition and Usage

The Infinity property is a numeric value that represents positive or negative infinity.

Infinity is displayed when a number is higher than 1.7976931348623157E+10308, and -Infinity is displayed when a number is lower than -1.7976931348623157E+10308.

Syntax

Infinity

Tips and Notes

Note: Anything divided by Infinity is 0 and anything multiplied by Infinity is Infinity.

Example

In this example we will show what happens if a number exceeds the infinity limit:

<script type="text/javascript">
var t1=1.7976931348623157E+10308
document.write(t1)
document.write("<br />")
var t2=-1.7976931348623157E+10308
document.write(t2)
</script>

The output of the code above will be:

Infinity
-Infinity


The isFinite() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The isFinite() Function

Definition and Usage

The isFinite() function is used to check if a value is a finite number.

Syntax

isFinite(number)

Parameter | Description
number | Required. The value to be tested

Example

In this example we use isFinite() to check for finite numbers:

<script type="text/javascript">
document.write(isFinite(123)+ "<br />")
document.write(isFinite(-1.23)+ "<br />")
document.write(isFinite(5-2)+ "<br />")
document.write(isFinite(0)+ "<br />")
document.write(isFinite("Hello")+ "<br />")
document.write(isFinite("2005/12/12")+ "<br />")
</script>

The output of the code above will be:

true
true
true
true
false
false


The isNaN() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The isNaN() Function

Definition and Usage

The isNaN() function is used to check if a value is not a number.

Syntax

isNaN(number)

Parameter | Description
number | Required. The value to be tested

Example

In this example we use isNaN() to check some values:

<script type="text/javascript">
document.write(isNaN(123)+ "<br />")
document.write(isNaN(-1.23)+ "<br />")
document.write(isNaN(5-2)+ "<br />")
document.write(isNaN(0)+ "<br />")
document.write(isNaN("Hello")+ "<br />")
document.write(isNaN("2005/12/12")+ "<br />")
</script>

The output of the code above will be:

false
false
false
false
true
true


The italics() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The italics() method

Definition and Usage

The italics() method is used to display a string in italic.

Syntax

stringObject.italics()

Example

In this example "Hello world!" will be displayed in italic:

<script type="text/javascript">
var str="Hello world!"
document.write(str.italics())
</script>


The join() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The join() method

Definition and Usage

The join() method is used to put all the elements of an array into a string.

The elements will be separated by a specified separator.

Syntax

arrayObject.join(separator)

Parameter | Description
separator | Optional. Specifies the separator to be used

Tips and Notes

Note: Comma is the default separator for the join() method.

Example

In this example we will create an array, and then put all the elements in a string:

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
document.write(arr.join() + "<br />")
document.write(arr.join("."))
</script>

The output of the code above will be:

Jani,Hege,Stale
Jani.Hege.Stale


The lastIndexOf() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The lastIndexOf() method

Definition and Usage

The lastIndexOf() method returns the position of the last occurrence of a specified string value, searching backwards from the specified position in a string.

Syntax

stringObject.lastIndexOf(searchvalue,fromindex)

Parameter | Description
search | Required. Specifies a string value to search for
fromindex | Optional. Specifies where to start the search. Starting backwards in the string

Tips and Notes

Note: The lastIndexOf() method is case sensitive!

Note: This method returns -1 if the string value to search for never occurs.

Example

In this example we will do different searches within a "Hello world!" string:

<script type="text/javascript">
var str="Hello world!"
document.write(str.lastIndexOf("Hello") + "<br />")
document.write(str.lastIndexOf("World") + "<br />")
document.write(str.lastIndexOf("world"))
</script>

The output of the code above will be:

0
-1
6


The length property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The length Property

Definition and Usage

The length property sets or returns the number of elements in an array.

Syntax

arrayObject.length

Example

In this example we will show how to use the length property to both return and set the length of an array:

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "John"
arr[1] = "Andy"
arr[2] = "Wendy"
document.write("Original length: " + arr.length)
document.write("<br />")
arr.length=5
document.write("New length: " + arr.length)
</script>

The output of the code above will be:

Original length: 3
New length: 5


The length property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The length Property

Definition and Usage

The length property returns the number of characters in a string.

Syntax

stringObject.length

Example

In this example we will show how to use the length property to return the number of characters in a string:

<script type="text/javascript">
var txt="Hello World!"
document.write(txt.length)
</script>

The output of the code above will be:

12


The link() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The link() method

Definition and Usage

The link() method is used to display a string as a hyperlink.

Syntax

stringObject.link()

Example

In this example "Free Web Tutorials!" will be displayed as a hyperlink:

<script type="text/javascript">
var str="Free Web Tutorials!"
document.write(str.link("http://www.w3schools.com"))
</script>


The log() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The log() method

Definition and Usage

The log() method returns the natural logarithm (base E) of a number.

Syntax

Math.log(x)

Parameter | Description
x | Required. A number

Tips and Notes

Note: If the parameter x is negative, NaN is returned.

Example

In the following example we will use the log() method on different numbers:

<script type="text/javascript">
document.write(Math.log(2.7183) + "<br />")
document.write(Math.log(2) + "<br />")
document.write(Math.log(1) + "<br />")
document.write(Math.log(0) + "<br />")
document.write(Math.log(-1))
</script>

The output of the code above will be:

1.0000066849139877
0.6931471805599453
0
-Infinity
NaN


The match() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The match() method

Definition and Usage

The match() method searches for a specified string value in a string.

This method is similar to indexOf() and lastIndexOf(), but it returns the specified string, instead of the position of the string.

Syntax

stringObject.match(searchvalue)

Parameter | Description
searchvalue | Required. Specifies a string value to search for

Tips and Notes

Note: The match() method is case sensitive!

Note: This method returns null if the string value to search for never occurs.

Example

In this example we will do different searches within a "Hello world!" string:

<script type="text/javascript">
var str="Hello world!"
document.write(str.match("world") + "<br />")
document.write(str.match("World") + "<br />")
document.write(str.match("worlld") + "<br />")
document.write(str.match("world!"))
</script>

The output of the code above will be:

world
null
null
world!


The max() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The max() method

Definition and Usage

The max() method returns the number with the highest value of two specified numbers.

Syntax

Math.max(x,y)

Parameter | Description
x | Required. A number
y | Required. A number

Example

In this example we will show how to use max() to return the number with the highest value of two specified numbers:

<script type="text/javascript">
document.write(Math.max(5,7) + "<br />")
document.write(Math.max(-3,5) + "<br />")
document.write(Math.max(-3,-5) + "<br />")
document.write(Math.max(7.25,7.30))
</script>

The output of the code above will be:

7
5
-3
7.3


The min() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The min() method

Definition and Usage

The min() method returns the number with the lowest value of two specified numbers.

Syntax

Math.min(x,y)

Parameter | Description
x | Required. A number
y | Required. A number

Example

In this example we will show how to use min() to return the number with the lowest value of two specified numbers:

<script type="text/javascript">
document.write(Math.min(5,7) + "<br />")
document.write(Math.min(-3,5) + "<br />")
document.write(Math.min(-3,-5) + "<br />")
document.write(Math.min(7.25,7.30))
</script>

The output of the code above will be:

5
-3
-5
7.25


The NaN Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The NaN Property

Definition and Usage

The NaN property indicates that a value is "Not a Number".

Syntax

NaN

Tips and Notes

Tip: Use the isNan() function to test a value to see if it is NaN.

Example

In this example we will test two strings and find out if one of them is NaN:

<script type="text/javascript">
var test1="300"
var test2="Hello World!"
document.write(Number(test1)+ "<br />")
document.write(Number(test2)+ "<br />")
document.write(isNaN(test1)+ "<br />")
document.write(isNaN(test2))
</script>

The output of the code above will be:

300
NaN
false
true


The Number() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The Number() Function

Definition and Usage

The Number() function converts the value of an object to a number.

Syntax

Number(object)

Parameter | Description
object | Required. A JavaScript object

Tips and Notes

Note: If the parameter is a Date object, the Number() function returns the number of milliseconds since midnight January 1, 1970 UTC.

Note: If the object's value cannot be converted to a number, the Number() function returns NaN.

Example

In this example we will try to convert different objects to numbers:

<script type="text/javascript">
var test1= new Boolean(true)
var test2= new Boolean(false)
var test3= new Date()
var test4= new String("999")
var test5= new String("999 888")
document.write(Number(test1)+ "<br />")
document.write(Number(test2)+ "<br />")
document.write(Number(test3)+ "<br />")
document.write(Number(test4)+ "<br />")
document.write(Number(test5)+ "<br />")
</script>

The output of the code above will be:

1
0
1130163301678
999
NaN


JavaScript Array Object Reference

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

JavaScript Array Object Reference

Array Object Methods

FF: Firefox, N: Netscape, IE: Internet Explorer

Method | Description | FF | N | IE
concat() | Joins two or more arrays and returns the result | 1 | 4 | 4
join() | Puts all the elements of an array into a string. The elements are separated by a specified delimiter | 1 | 3 | 4
pop() | Removes and returns the last element of an array | 1 | 4 | 5.5
push() | Adds one or more elements to the end of an array and returns the new length | 1 | 4 | 5.5
reverse() | Reverses the order of the elements in an array | 1 | 3 | 4
shift() | Removes and returns the first element of an array | 1 | 4 | 5.5
slice() | Returns selected elements from an existing array | 1 | 4 | 4
sort() | Sorts the elements of an array | 1 | 3 | 4
splice() | Removes and adds new elements to an array | 1 | 4 | 5.5
toSource() | Represents the source code of an object | 1 | 4 | -
toString() | Converts an array to a string and returns the result | 1 | 3 | 4
unshift() | Adds one or more elements to the beginning of an array and returns the new length | 1 | 4 | -
valueOf() | Returns the primitive value of an Array object | 1 | 2 | 4

Array Object Properties

Property | Description | FF | N | IE
constructor | A reference to the function that created the object | 1 | 2 | 4
index |  | 1 | 3 | 4
input |  | 1 | 3 | 4
length | Sets or returns the number of elements in an array | 1 | 2 | 4
prototype | Allows you to add properties and methods to the object | 1 | 2 | 4


JavaScript Boolean Object Reference

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

JavaScript Boolean Object Reference

Boolean Object Methods

FF: Firefox, N: Netscape, IE: Internet Explorer

Method | Description | FF | N | IE
toSource() | Represents the source code of an object | 1 | 4 | -
toString() | Converts a Boolean value to a string and returns the result | 1 | 4 | 4
valueOf() | Returns the primitive value of a Boolean object | 1 | 4 | 4

Boolean Object Properties

Property | Description | FF | N | IE
constructor | A reference to the function that created the object | 1 | 2 | 4
prototype | Allows you to add properties and methods to the object | 1 | 2 | 4


JavaScript Date Object Reference

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

JavaScript Date Object Reference

Date Object Methods

FF: Firefox, N: Netscape, IE: Internet Explorer

Method | Description | FF | N | IE
Date() | Returns today's date and time | 1 | 2 | 3
getDate() | Returns the day of the month from a Date object (from 1-31) | 1 | 2 | 3
getDay() | Returns the day of the week from a Date object (from 0-6) | 1 | 2 | 3
getMonth() | Returns the month from a Date object (from 0-11) | 1 | 2 | 3
getFullYear() | Returns the year, as a four-digit number, from a Date object | 1 | 4 | 4
getYear() | Returns the year, as a two-digit or a four-digit number, from a Date object. Use getFullYear() instead !! | 1 | 2 | 3
getHours() | Returns the hour of a Date object (from 0-23) | 1 | 2 | 3
getMinutes() | Returns the minutes of a Date object (from 0-59) | 1 | 2 | 3
getSeconds() | Returns the seconds of a Date object (from 0-59) | 1 | 2 | 3
getMilliseconds() | Returns the milliseconds of a Date object (from 0-999) | 1 | 4 | 4
getTime() | Returns the number of milliseconds since midnight Jan 1, 1970 | 1 | 2 | 3
getTimezoneOffset() | Returns the difference in minutes between local time and Greenwich Mean Time (GMT) | 1 | 2 | 3
getUTCDate() | Returns the day of the month from a Date object according to universal time (from 1-31) | 1 | 4 | 4
getUTCDay() | Returns the day of the week from a Date object according to universal time (from 0-6) | 1 | 4 | 4
getUTCMonth() | Returns the month from a Date object according to universal time (from 0-11) | 1 | 4 | 4
getUTCFullYear() | Returns the four-digit year from a Date object according to universal time | 1 | 4 | 4
getUTCHours() | Returns the hour of a Date object according to universal time (from 0-23) | 1 | 4 | 4
getUTCMinutes() | Returns the minutes of a Date object according to universal time (from 0-59) | 1 | 4 | 4
getUTCSeconds() | Returns the seconds of a Date object according to universal time (from 0-59) | 1 | 4 | 4
getUTCMilliseconds() | Returns the milliseconds of a Date object according to universal time (from 0-999) | 1 | 4 | 4
parse() | Takes a date string and returns the number of milliseconds since midnight of January 1, 1970 | 1 | 2 | 3
setDate() | Sets the day of the month in a Date object (from 1-31) | 1 | 2 | 3
setMonth() | Sets the month in a Date object (from 0-11) | 1 | 2 | 3
setFullYear() | Sets the year in a Date object (four digits) | 1 | 4 | 4
setYear() | Sets the year in the Date object (two or four digits). Use setFullYear() instead !! | 1 | 2 | 3
setHours() | Sets the hour in a Date object (from 0-23) | 1 | 2 | 3
setMinutes() | Set the minutes in a Date object (from 0-59) | 1 | 2 | 3
setSeconds() | Sets the seconds in a Date object (from 0-59) | 1 | 2 | 3
setMilliseconds() | Sets the milliseconds in a Date object (from 0-999) | 1 | 4 | 4
setTime() | Calculates a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970 | 1 | 2 | 3
setUTCDate() | Sets the day of the month in a Date object according to universal time (from 1-31) | 1 | 4 | 4
setUTCMonth() | Sets the month in a Date object according to universal time (from 0-11) | 1 | 4 | 4
setUTCFullYear() | Sets the year in a Date object according to universal time (four digits) | 1 | 4 | 4
setUTCHours() | Sets the hour in a Date object according to universal time (from 0-23) | 1 | 4 | 4
setUTCMinutes() | Set the minutes in a Date object according to universal time (from 0-59) | 1 | 4 | 4
setUTCSeconds() | Set the seconds in a Date object according to universal time (from 0-59) | 1 | 4 | 4
setUTCMilliseconds() | Sets the milliseconds in a Date object according to universal time (from 0-999) | 1 | 4 | 4
toSource() | Represents the source code of an object | 1 | 4 | -
toString() | Converts a Date object to a string | 1 | 2 | 4
toGMTString() | Converts a Date object, according to Greenwich time, to a string. Use toUTCString() instead !! | 1 | 2 | 3
toUTCString() | Converts a Date object, according to universal time, to a string | 1 | 4 | 4
toLocaleString() | Converts a Date object, according to local time, to a string | 1 | 2 | 3
UTC() | Takes a date and returns the number of milliseconds since midnight of January 1, 1970 according to universal time | 1 | 2 | 3
valueOf() | Returns the primitive value of a Date object | 1 | 2 | 4

Date Object Properties

Property | Description | FF | N | IE
constructor | A reference to the function that created the object | 1 | 4 | 4
prototype | Allows you to add properties and methods to the object | 1 | 3 | 4


JavaScript Function Reference

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

JavaScript Function Reference

The top-level properties and functions can be used on all of the built-in JavaScript objects.

Top-level Functions

FF: Firefox, N: Netscape, IE: Internet Explorer

Function | Description | FF | N | IE
decodeURI() | Decodes an encoded URI | 1 | 4 | 5.5
decodeURIComponent() | Decodes an encoded URI component | 1 | 4 | 5.5
encodeURI() | Encodes a string as a URI | 1 | 4 | 5.5
encodeURIComponent() | Encodes a string as a URI component | 1 | 4 | 5.5
escape() | Encodes a string | 1 | - | 3
eval() | Evaluates a string and executes it as if it was script code | 1 | 2 | 3
isFinite() | Checks if a value is a finite number | 1 | 4 | 4
isNaN() | Checks if a value is not a number | 1 | 2 | 3
Number() | Converts an object's value to a number | 1 |  |
parseFloat() | Parses a string and returns a floating point number | 1 | 2 | 3
parseInt() | Parses a string and returns an integer | 1 | 2 | 3
String() | Converts an object's value to a string | 1 |  |
unescape() | Decodes a string encoded by escape() | 1 | - | 3

Top-level Properties

Property | Description | FF | N | IE
Infinity | A numeric value that represents positive or negative infinity | 1 | 4 | 4
NaN | Indicates that a value is "Not a Number" | 1 | 4 | 4
undefined | Indicates that a variable has not been assigned a value | 1 | 4 | 5.5


JavaScript Math Object Reference

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

JavaScript Math Object Reference

Math Object Methods

FF: Firefox, N: Netscape, IE: Internet Explorer

Method | Description | FF | N | IE
abs(x) | Returns the absolute value of a number | 1 | 2 | 3
acos(x) | Returns the arccosine of a number | 1 | 2 | 3
asin(x) | Returns the arcsine of a number | 1 | 2 | 3
atan(x) | Returns the arctangent of x as a numeric value between -PI/2 and PI/2 radians | 1 | 2 | 3
atan2(y,x) | Returns the angle theta of an (x,y) point as a numeric value between -PI/2 and PI/2 radians | 1 | 2 | 3
ceil(x) | Returns the value of a number rounded upwards to the nearest integer | 1 | 2 | 3
cos(x) | Returns the cosine of a number | 1 | 2 | 3
exp(x) | Returns the value of Ex | 1 | 2 | 3
floor(x) | Returns the value of a number rounded downwards to the nearest integer | 1 | 2 | 3
log(x) | Returns the natural logarithm (base E) of a number | 1 | 2 | 3
max(x,y) | Returns the number with the highest value of x and y | 1 | 2 | 3
min(x,y) | Returns the number with the lowest value of x and y | 1 | 2 | 3
pow(x,y) | Returns the value of x to the power of y | 1 | 2 | 3
random() | Returns a random number between 0 and 1 | 1 | 2 | 3
round(x) | Rounds a number to the nearest integer | 1 | 2 | 3
sin(x) | Returns the sine of a number | 1 | 2 | 3
sqrt(x) | Returns the square root of a number | 1 | 2 | 3
tan(x) | Returns the tangent of an angle | 1 | 2 | 3
toSource() | Represents the source code of an object | 1 | 4 | -
valueOf() | Returns the primitive value of a Math object | 1 | 2 | 4

Math Object Properties

Property | Description | FF | N | IE
constructor | A reference to the function that created the object | 1 | 2 | 4
E | Returns Euler's constant (approx. 2.718) | 1 | 2 | 3
LN2 | Returns the natural logarithm of 2 (approx. 0.693) | 1 | 2 | 3
LN10 | Returns the natural logarithm of 10 (approx. 2.302) | 1 | 2 | 3
LOG2E | Returns the base-2 logarithm of E (approx. 1.442) | 1 | 2 | 3
LOG10E | Returns the base-10 logarithm of E (approx. 0.434) | 1 | 2 | 3
PI | Returns PI (approx. 3.14159) | 1 | 2 | 3
prototype | Allows you to add properties and methods to the object | 1 | 2 | 4
SQRT1_2 | Returns the square root of 1/2 (approx. 0.707) | 1 | 2 | 3
SQRT2 | Returns the square root of 2 (approx. 1.414) | 1 | 2 | 3


JavaScript String Object Reference

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

JavaScript String Object Reference

String Object Methods

FF: Firefox, N: Netscape, IE: Internet Explorer

Method | Description | FF | N | IE
anchor() | Creates an HTML anchor | 1 | 2 | 3
big() | Displays a string in a big font | 1 | 2 | 3
blink() | Displays a blinking string | 1 | 2 |
bold() | Displays a string in bold | 1 | 2 | 3
charAt() | Returns the character at a specified position | 1 | 2 | 3
charCodeAt() | Returns the Unicode of the character at a specified position | 1 | 4 | 4
concat() | Joins two or more strings | 1 | 4 | 4
fixed() | Displays a string as teletype text | 1 | 2 | 3
fontcolor() | Displays a string in a specified color | 1 | 2 | 3
fontsize() | Displays a string in a specified size | 1 | 2 | 3
fromCharCode() | Takes the specified Unicode values and returns a string | 1 | 4 | 4
indexOf() | Returns the position of the first occurrence of a specified string value in a string | 1 | 2 | 3
italics() | Displays a string in italic | 1 | 2 | 3
lastIndexOf() | Returns the position of the last occurrence of a specified string value, searching backwards from the specified position in a string | 1 | 2 | 3
link() | Displays a string as a hyperlink | 1 | 2 | 3
match() | Searches for a specified string value in a string | 1 | 4 | 4
replace() | Replaces some characters with some other characters in a string | 1 | 4 | 4
search() | Searches a string for a specified value | 1 | 4 | 4
slice() | Extracts a part of a string and returns the extracted part in a new string | 1 | 4 | 4
small() | Displays a string in a small font | 1 | 2 | 3
split() | Splits a string into an array of strings | 1 | 4 | 4
strike() | Displays a string with a strikethrough | 1 | 2 | 3
sub() | Displays a string as subscript | 1 | 2 | 3
substr() | Extracts a specified number of characters in a string, from a start index | 1 | 4 | 4
substring() | Extracts the characters in a string between two specified indices | 1 | 2 | 3
sup() | Displays a string as superscript | 1 | 2 | 3
toLowerCase() | Displays a string in lowercase letters | 1 | 2 | 3
toUpperCase() | Displays a string in uppercase letters | 1 | 2 | 3
toSource() | Represents the source code of an object | 1 | 4 | -
valueOf() | Returns the primitive value of a String object | 1 | 2 | 4

String Object Properties

Property | Description | FF | N | IE
constructor | A reference to the function that created the object | 1 | 4 | 4
length | Returns the number of characters in a string | 1 | 2 | 3
prototype | Allows you to add properties and methods to the object | 1 | 2 | 4


The onabort event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onabort event

Definition and Usage

The onabort event occurs when loading of an image is aborted.

Syntax

onabort="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<img>

Supported by the following JavaScript objects:

image

Example 1

In this example an alert box will be displayed if the loading of the image is aborted:

<img src="image_w3default.gif"
onabort="alert('Error: Loading of the image was aborted')">

Example 2

In this example we will call a function if the loading of the image is aborted:

<html>
<head>
<script type="text/javascript">
function abortImage()
{
alert('Error: Loading of the image was aborted')
}
</script>
</head>
<body>
<img src="image_w3default.gif"
onabort="abortImage()">
</body>
</html>


The onblur event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onblur event

Definition and Usage

The onblur event occurs when an object loses focus.

Syntax

onblur="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <acronym>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <button>, <caption>, <cite>, <dd>, <del>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <frame>, <frameset>, <h1> to <h6>, <hr>, <i>, <iframe>, <img>, <input>, <ins>, <kbd>, <label>, <legend>, <li>, <object>, <ol>, <p>, <pre>, <q>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

button, checkbox, fileUpload, layer, frame, password, radio, reset, submit, text, textarea, window

Example

In this example we will execute some JavaScript code when a user leaves an input field:

<html>
<head>
<script type="text/javascript">
function upperCase()
{
var x=document.getElementById("fname").value
document.getElementById("fname").value=x.toUpperCase()
}
</script>
</head>
<body>
Enter your name:
<input type="text" id="fname" onblur="upperCase()">
</body>
</html>

The output of the code above will be:

Enter your name:


The onchange event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onchange event

Definition and Usage

The onchange event occurs when the content of a field changes.

Syntax

onchange="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<input type="text">, <select>, <textarea>

Supported by the following JavaScript objects:

fileUpload, select, text, textarea

Example

In this example we will execute some JavaScript code when a user changes the content of an input field:

<html>
<head>
<script type="text/javascript">
function upperCase(x)
{
var y=document.getElementById(x).value
document.getElementById(x).value=y.toUpperCase()
}
</script>
</head>
<body>
Enter your name:
<input type="text" id="fname"
onchange="upperCase(this.id)">
</body>
</html>

The output of the code above will be:

Enter your name:


The onclick event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onclick event

Definition and Usage

The onclick event occurs when an object gets clicked.

Syntax

onclick="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <object>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

button, document, checkbox, link, radio, reset, submit

Example

In this example the text in the first input field will be copied to the second input field when a button is clicked:

<html>
<body>
Field1: <input type="text" id="field1" value="Hello World!">
<br />
Field2: <input type="text" id="field2">
<br /><br />
Click the button below to copy the content of Field1 to Field2.
<br />
<button onclick="document.getElementById('field2').value=
document.getElementById('field1').value">Copy Text</button>
</body>
</html>

The output of the code above will be:

Field1:
Field2:

Click the button below to copy the content of Field1 to Field2.


The ondblclick event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The ondblclick event

Definition and Usage

The ondblclick event occurs when an object gets double-clicked.

Syntax

ondblclick="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <object>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

document, link

Example

In this example the second field changes according to the first field when you double-click on the button:

<html>
<body>
Field1: <input type="text" id="field1" value="Hello World!">
<br />
Field2: <input type="text" id="field2">
<br /><br />
Click the button below to copy the content of Field1 to Field2.
<br />
<button ondblclick="document.getElementById('field2').value=
document.getElementById('field1').value">Copy Text</button>
</body>
</html>

The output of the code above will be:

Field1:
Field2:

Double-click the button below to copy the content of Field1 to Field2.


The onerror event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onerror event

Definition and Usage

The onerror event is triggered when an error occurs loading a document or an image.

Syntax

onerror="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<img>, <object>, <style>

Supported by the following JavaScript objects:

window, image

Example

In this example an alert box will be displayed if an error occurs when loading an image:

<img src="image.gif"
onerror="alert('The image could not be loaded.')">


The onfocus event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onfocus event

Definition and Usage

The onfocus event occurs when an object gets focus.

Syntax

onfocus="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <acronym>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <button>, <caption>, <cite>, <dd>, <del>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <frame>, <frameset>, <h1> to <h6>, <hr>, <i>, <iframe>, <img>, <input>, <ins>, <kbd>, <label>, <legend>, <li>, <object>, <ol>, <p>, <pre>, <q>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

button, checkbox, fileUpload, layer, frame, password, radio, reset, select, submit, text, textarea, window

Example

In this example the background color of the input fields change when they get focus:

<html>
<head>
<script type="text/javascript">
function setStyle(x)
{
document.getElementById(x).style.background="yellow"
}
</script>
</head>
<body>
First name: <input type="text"
onfocus="setStyle(this.id)" id="fname">
<br />
Last name: <input type="text"
onfocus="setStyle(this.id)" id="lname">
</body>
</html>

The output of the code above will be:

First name:
Last name:


The onkeydown event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onkeydown event

Definition and Usage

The onkeydown event occurs when a keyboard key is pressed.

Syntax

onkeydown="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <acronym>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <del>, <dfn>, <div>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <object>, <ol>, <p>, <pre>, <q>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

document, image, link, textarea

Tips and Notes

Browser differences: Internet Explorer uses event.keyCode to retrieve the character that was pressed and Netscape/Firefox/Opera uses event.which.

Example

In this example the user cannot type numbers into the input field:

<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum
var keychar
var numcheck
if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
keychar = String.fromCharCode(keynum)
numcheck = /\d/
return !numcheck.test(keychar)
}
</script>
<form>
<input type="text" onkeydown="return noNumbers(event)" />
</form>
</html>

The output of the code above will be:


The onkeypress event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onkeypress event

Definition and Usage

The onkeydown event occurs when a keyboard key is pressed or held down.

Syntax

onkeypress="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <acronym>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <del>, <dfn>, <div>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <object>, <ol>, <p>, <pre>, <q>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

document, image, link, textarea

Tips and Notes

Browser differences: Internet Explorer uses event.keyCode to retrieve the character that was pressed and Netscape/Firefox/Opera uses event.which.

Example

In this example the user cannot type numbers into the input field:

<html>
<body>
<script type="text/javascript">
function noNumbers(e)
{
var keynum
var keychar
var numcheck
if(window.event) // IE
{
keynum = e.keyCode
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which
}
keychar = String.fromCharCode(keynum)
numcheck = /\d/
return !numcheck.test(keychar)
}
</script>
<form>
<input type="text" onkeypress="return noNumbers(event)" />
</form>
</html>

The output of the code above will be:


The onKeyDown event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onKeyUp event

Definition and Usage

The onkeyup event occurs when a keyboard key is released.

Syntax

onkeyup="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <acronym>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <del>, <dfn>, <div>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <object>, <ol>, <p>, <pre>, <q>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

document, image, link, textarea

Example

When typing letters in the input field in the following example, the letters will change to uppercase (one by one):

<html>
<head>
<script type="text/javascript">
function upperCase(x)
{
var y=document.getElementById(x).value
document.getElementById(x).value=y.toUpperCase()
}
</script>
</head>
<body>
Enter your name: <input type="text"
id="fname" onkeyup="upperCase(this.id)">
</body>
</html>

The output of the code above will be:

Enter your name:


The onload event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onload event

Definition and Usage

The onload event occurs immediately after a page or an image is loaded.

Syntax

onload="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<body>, <frame>, <frameset>, <iframe>, <img>, <link>, <script>

Supported by the following JavaScript objects:

image, layer, window

Example

In this example the text "Page is loaded" will be displayed in the status bar:

<html>
<head>
<script type="text/javascript">
function load()
{
window.status="Page is loaded"
}
</script>
</head>
<body onload="load()">
</body>
</html>


The onmousedown event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onmousedown event

Definition and Usage

The onmousedown event occurs when a mouse button is clicked.

Syntax

onmousedown="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

button, document, link

Example 1

In this example an alert box is displayed when clicking on the picture:

<img src="image_w3default.gif"
onmousedown="alert('You clicked the picture!')">

The output of the code above will be (click on the picture):

Example 2

In this example an alert box will alert the tag name of the element you clicked on:

<html>
<head>
<script type="text/javascript">
function whichElement(e)
{
var targ
if (!e) var e = window.event
if (e.target) targ = e.target
else if (e.srcElement) targ = e.srcElement
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode
var tname
tname=targ.tagName
alert("You clicked on a " + tname + " element.")
}
</script>
</head>
<body onmousedown="whichElement(event)">
<h2>This is a header</h2>
<p>This is a paragraph</p>
<img border="0" src="ball16.gif" alt="Ball">
</body>
</html>


The onmousemove event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onmousemove event

Definition and Usage

The onmousemove event occurs when the mouse pointer is moved.

Syntax

onmousemove="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

onmousemove is, by default, not an event of any object, because mouse movement happens very frequently.

Tips and Notes

Note: Each time a user moves the mouse one pixel, a mousemove event occurs. It takes system resources to process all mousemove events. Use this event carefully!

Example

In the following example we will display an alert box when the user moves the mouse pointer over the image:

<img src="image_w3default.gif" alt="W3Schools"
onmousemove="alert('Visit W3Schools!')" />

The output of the code above will be:

W3Schools


The onmouseout event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onmouseout event

Definition and Usage

The onmouseout event occurs when the mouse pointer moves away from a specified object.

Syntax

onmouseout="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

layer, link

Example 1

In the following example we will display an alert box when the user moves the mouse pointer away from the image:

<img src="image_w3default.gif" alt="W3Schools"
onmouseout="alert('Visit W3Schools!')" />

The output of the code above will be:

W3Schools

Example 2

In the following example we will add an image that should act as a link button on a web page. We will then add an onMouseOver event and an onMouseOut event that will run two JavaScript functions that will change between two images:

<html>
<head>
<script type="text/javascript">
function mouseOver()
{
document.b1.src ="b_blue.gif"
}
function mouseOut()
{
document.b1.src ="b_pink.gif"
}
</script>
</head>
<body>
<a href="http://www.w3schools.com" target="_blank"
onmouseover="mouseOver()"
onmouseout="mouseOut()">
<img border="0" alt="Visit W3Schools!"
src="b_pink.gif" name="b1" /></a>
</body>
</html>

The output of the code above will be:

Visit W3Schools!


The onmouseover event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onmouseover event

Definition and Usage

The onmouseover event occurs when the mouse pointer moves over a specified object.

Syntax

onmouseover="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

layer, link

Example 1

In the following example we will display an alert box when the user moves the mouse pointer over the image:

<img src="image_w3default.gif" alt="W3Schools"
onmouseover="alert('Visit W3Schools!')" />

The output of the code above will be:

W3Schools

Example 2

In the following example we will add an image that should act as a link button on a web page. We will then add an onMouseOver event and an onMouseOut event that will run two JavaScript functions that will change between two images:

<html>
<head>
<script type="text/javascript">
function mouseOver()
{
document.b1.src ="b_blue.gif"
}
function mouseOut()
{
document.b1.src ="b_pink.gif"
}
</script>
</head>
<body>
<a href="http://www.w3schools.com" target="_blank"
onmouseover="mouseOver()"
onmouseout="mouseOut()">
<img border="0" alt="Visit W3Schools!"
src="b_pink.gif" name="b1" /></a>
</body>
</html>

The output of the code above will be:

Visit W3Schools!


The onmouseup event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onmouseup event

Definition and Usage

The onmouseup event occurs when a mouse button is released.

Syntax

onmouseup="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <address>, <area>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <map>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <tbody>, <td>, <textarea>, <tfoot>, <th>, <thead>, <tr>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

button, document, link

Example 1

In this example an alert box is displayed when the mouse button is released after clicking the picture:

<img src="image_w3default.gif"
onmouseup="alert('You clicked the picture!')">

The output of the code above will be (click on the picture):

<img src="image_w3default.gif" onMouseUp="alert('You clicked the picture!')">

Example 2

In this example an alert box will alert the tag name of the element you clicked on:

<html>
<head>
<script type="text/javascript">
function whichElement(e)
{
var targ
if (!e) var e = window.event
if (e.target) targ = e.target
else if (e.srcElement) targ = e.srcElement
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode
var tname
tname=targ.tagName
alert("You clicked on a " + tname + " element.")
}
</script>
</head>
<body onmouseup="whichElement(event)">
<h2>This is a header</h2>
<p>This is a paragraph</p>
<img border="0" src="ball16.gif" alt="Ball">
</body>
</html>


The onreset event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onreset event

Definition and Usage

The onreset event occurs when the reset button in a form is clicked.

Syntax

onreset="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<form>

Supported by the following JavaScript objects:

form

Example

In this example the form changes back to the default values and displays an alert box when the reset button is clicked:

<form onreset="alert('The form will be reset')">
Firstname: <input type="text" name="fname" value="John" />
<br />
Lastname: <input type="text" name="lname" />
<br /><br />
<input type="reset" value="Reset">
</form>

The output of the code above will be:

Firstname:
Lastname:


The onresize event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onresize event

Definition and Usage

The onresize event occurs when a window or frame is resized.

Syntax

onresize="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<a>, <address>, <b>, <big>, <blockquote>, <body>, <button>, <cite>, <code>, <dd>, <dfn>, <div>, <dl>, <dt>, <em>, <fieldset>, <form>, <frame>, <h1> to <h6>, <hr>, <i>, <img>, <input>, <kbd>, <label>, <legend>, <li>, <object>, <ol>, <p>, <pre>, <samp>, <select>, <small>, <span>, <strong>, <sub>, <sup>, <table>, <textarea>, <tt>, <ul>, <var>

Supported by the following JavaScript objects:

window

Example

In this example an alert box will be displayed when a user tries to resize the window:

<body onresize="alert('You have changed the size of the window')">
</body>


The onselect event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onselect event

Definition and Usage

The onselect event occurs when text is selected in a text or textarea field.

Syntax

onselect="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<input type="text">, <textarea>

Supported by the following JavaScript objects:

text, textarea

Example

In this example an alert box will be displayed if some of the text is selected:

<form>
Select text: <input type="text" value="Hello world!"
onselect="alert('You have selected some of the text.')">
<br /><br />
Select text: <textarea cols="20" rows="5"
onselect="alert('You have selected some of the text.')">
Hello world!</textarea>
</form>

The output of the code above will be:

Select text:

Select text:


The onsubmit event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onsubmit event

Definition and Usage

The onsubmit event occurs when the submit button in a form is clicked.

Syntax

onsubmit="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<form>

Supported by the following JavaScript objects:

form

Example

In this example an alert box displays when a submit box is used:

<form name="testform" action="jsref_onsubmit.asp"
onsubmit="alert('Hello ' + testform.fname.value +'!')">
What is your name?<br />
<input type="text" name="fname" />
<input type="submit" value="Submit" />
</form>

The output of the code above will be:

What is your name?


The onunload event

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The onunload event

Definition and Usage

The onunload event occurs when a user exits a page.

Syntax

onunload="SomeJavaScriptCode"

Parameter | Description
SomeJavaScriptCode | Required. Specifies a JavaScript to be executed when the event occurs.

Supported by the following HTML tags:

<body>, <frameset>

Supported by the following JavaScript objects:

window

Example

In this example an alert box will be displayed when the page is closed:

<body onunload="alert('The onunload event was triggered')">
</body>


The parse() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The parse() method

Definition and Usage

The parse() method takes a date string and returns the number of milliseconds since midnight of January 1, 1970.

Syntax

Date.parse(datestring)

Parameter | Description
datestring | Required. A string representing a date

Example

In this example we will get how many milliseconds there are from 1970/01/01 to 2005/07/08:

<script type="text/javascript">
var d = Date.parse("Jul 8, 2005")
document.write(d)
</script>

The output of the code above will be:

1120773600000

Example 2

Now we will convert the output from the example above into years:

<script type="text/javascript">
var minutes = 1000 * 60
var hours = minutes * 60
var days = hours * 24
var years = days * 365
var t = Date.parse("Jul 8, 2005")
var y = t/years
document.write("It's been: " + y + " years from 1970/01/01")
document.write(" to 2005/07/08!")
</script>

The output of the code above will be:

It's been: 35.53949771689498 years from 1970/01/01 to 2005/07/08!


The parseFloat() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The parseFloat() Function

Definition and Usage

The parseFloat() function parses a string and returns a floating point number.

This function determines if the first character in the specified string is a number. If it is, it parses the string until it reaches the end of the number, and returns the number as a number, not as a string.

Syntax

parseFloat(string)

Parameter | Description
string | Required. The string to be parsed

Tips and Notes

Note: Only the first number in the string is returned!

Note: Leading and trailing spaces are allowed.

Note: If the first character cannot be converted to a number, parseFloat() returns NaN.

Example

In this example we will use parseFloat() to parse different strings:

<script type="text/javascript">
document.write(parseFloat("10") + "<br />")
document.write(parseFloat("10.00") + "<br />")
document.write(parseFloat("10.33") + "<br />")
document.write(parseFloat("34 45 66") + "<br />")
document.write(parseFloat(" 60 ") + "<br />")
document.write(parseFloat("40 years") + "<br />")
document.write(parseFloat("He was 40") + "<br />")
</script>

The output of the code above will be:

10
10
10.33
34
60
40
NaN


The parseInt() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The parseInt() Function

Definition and Usage

The parseInt() function parses a string and returns an integer.

The radix parameter is used to specify which numeral system to be used, for example, a radix of 16 (hexadecimal) indicates that the number in the string should be parsed from a hexadecimal number to a decimal number.

If the radix parameter is omitted, JavaScript assumes the following:

  • If the string begins with "0x", the radix is 16 (hexadecimal)
  • If the string begins with "0", the radix is 8 (octal). This feature is deprecated
  • If the string begins with any other value, the radix is 10 (decimal)

Syntax

parseInt(string, radix)

Parameter | Description
string | Required. The string to be parsed
radix | Optional. A number (from 2 to 36) that represents the numeral system to be used

Tips and Notes

Note: Only the first number in the string is returned!

Note: Leading and trailing spaces are allowed.

Note: If the first character cannot be converted to a number, parseInt() returns NaN.

Example

In this example we will use parseInt() to parse different strings:

<script type="text/javascript">
document.write(parseInt("10") + "<br />")
document.write(parseInt("10.00") + "<br />")
document.write(parseInt("10.33") + "<br />")
document.write(parseInt("34 45 66") + "<br />")
document.write(parseInt(" 60 ") + "<br />")
document.write(parseInt("40 years") + "<br />")
document.write(parseInt("He was 40") + "<br />")

document.write("<br />")

document.write(parseInt("10")+ "<br />")
document.write(parseInt("10",10)+ "<br />")

document.write(parseInt("010")+ "<br />")
document.write(parseInt("10",8)+ "<br />")

document.write(parseInt("0x10")+ "<br />")
document.write(parseInt("10",16)+ "<br />")
</script>

The output of the code above will be:

10
10
10
34
60
40
NaN
10
10
8
8
16
16


The pop() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The pop() method

Definition and Usage

The pop() method is used to remove and return the last element of an array.

Syntax

arrayObject.pop()

Tips and Notes

Note: This method changes the length of the array.

Tip: To remove and return the first element of an array, use the shift() method.

Example

In this example we will create an array, and then remove the last element of the array. Note that this will also change the length of the array:

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
document.write(arr + "<br />")
document.write(arr.pop() + "<br />")
document.write(arr)
</script>

The output of the code above will be:

Jani,Hege,Stale
Stale
Jani,Hege


The pow() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The pow() method

Definition and Usage

The pow() method returns the value of x to the power of y (xy).

Syntax

Math.pow(x,y)

Parameter | Description
x | Required. A number
y | Required. A number

Example

In the following example we will use the pow() method on different number combinations:

<script type="text/javascript">
document.write(Math.pow(0,0) + "<br />")
document.write(Math.pow(0,1) + "<br />")
document.write(Math.pow(1,1) + "<br />")
document.write(Math.pow(1,10) + "<br />")
document.write(Math.pow(2,3) + "<br />")
document.write(Math.pow(-2,3) + "<br />")
document.write(Math.pow(2,4) + "<br />")
document.write(Math.pow(-2,4) + "<br />")
</script>

The output of the code above will be:

1
0
1
1
8
-8
16
16


The prototype property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The prototype Property

Definition and Usage

The prototype property allows you to add properties and methods to an object.

Syntax

object.prototype.name=value

Example 1

In this example we will show how to use the prototype property to add a property to an object:

<script type="text/javascript">
function employee(name,jobtitle,born)
{
this.name=name
this.jobtitle=jobtitle
this.born=born
}
var fred=new employee("Fred Flintstone","Caveman",1970)
employee.prototype.salary=null
fred.salary=20000
document.write(fred.salary)
</script>

The output of the code above will be:

20000


The push() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The push() method

Definition and Usage

The push() method adds one or more elements to the end of an array and returns the new length.

Syntax

arrayObject.push(newelement1,newelement2,....,newelementX)

Parameter | Description
newelement1 | Required. The first element to add to the array
newelement2 | Optional. The second element to add to the array
newelementX | Optional. Several elements may be added

Tips and Notes

Note: This method changes the length of the array.

Tip: To add one or more elements to the beginning of an array, use the unshift() method.

Example

In this example we will create an array, and then change the length of it by adding a element:

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
document.write(arr + "<br />")
document.write(arr.push("Kai Jim") + "<br />")
document.write(arr)
</script>

The output of the code above will be:

Jani,Hege,Stale
4
Jani,Hege,Stale,Kai Jim


The random() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The random() method

Definition and Usage

The random() method returns a random number between 0 and 1.

Syntax

Math.random()

Example

In this example we will get a random number between 0 and 1:

<script type="text/javascript">
document.write(Math.random())
</script>

The output of the code above can be:

0.9825498471960034


The replace() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The replace() method

Definition and Usage

The replace() method is used to replace some characters with some other characters in a string.

Syntax

stringObject.replace(findstring,newstring)

Parameter | Description
findstring | Required. Specifies a string value to find. To perform a global search add a 'g' flag to this parameter and to perform a case-insensitive search add an 'i' flag
newstring | Required. Specifies the string to replace the found value from findstring

Tips and Notes

Note: The replace() method is case sensitive.

Example 1 - Standard Replace

In the following example we will replace the word Microsoft with W3Schools:

<script type="text/javascript">
var str="Visit Microsoft!"
document.write(str.replace(/Microsoft/, "W3Schools"))
</script>

The output of the code above will be:

Visit W3Schools!

Note: In the following example the word Microsoft will not be replaced (because the replace() method is case sensitive):

<script type="text/javascript">
var str="Visit Microsoft!"
document.write(str.replace(/microsoft/, "W3Schools"))
</script>

The output of the code above will be:

Visit Microsoft!

Example 2 - Case-insensitive Search

In the following example we will perform a case-insensitive search, and the word Microsoft will be replaced:

<script type="text/javascript">
var str="Visit Microsoft!"
document.write(str.replace(/microsoft/i, "W3Schools"))
</script>

The output of the code above will be:

Visit W3Schools!

Example 3 - Global Search

In the following example we will perform a global match, and the word Microsoft will be replaced each time it is found:

<script type="text/javascript">
var str="Welcome to Microsoft! "
str=str + "We are proud to announce that Microsoft have "
str=str + "one of the largest Web Developers site in the world."
document.write(str.replace(/Microsoft/g, "W3Schools"))
</script>

The output of the code above will be:

Welcome to W3Schools! We are proud to announce that W3Schools
have one of the largest Web Developers site in the world.

Example 4 - Global and Case-insensitive Search

In the following example we will perform a global and case-insensitive match, and the word Microsoft will be replaced each time it is found, independent of upper and lower case characters:

<script type="text/javascript">
var str="Welcome to Microsoft! "
str=str + "We are proud to announce that Microsoft have "
str=str + "one of the largest Web Developers site in the world."
document.write(str.replace(/microsoft/gi, "W3Schools"))
</script>

The output of the code above will be:

Welcome to W3Schools! We are proud to announce that W3Schools
have one of the largest Web Developers site in the world.


The reverse() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The reverse() method

Definition and Usage

The reverse() method is used to reverse the order of the elements in an array.

Syntax

arrayObject.reverse()

Tips and Notes

Note: The reverse() method changes the original array.

Example

In this example we will create an array, and then reverse the order of it:

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
document.write(arr + "<br />")
document.write(arr.reverse())
</script>

The output of the code above will be:

Jani,Hege,Stale
Stale,Hege,Jani


The round() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The round() method

Definition and Usage

The round() method rounds a number to the nearest integer.

Syntax

Math.round(x)

Parameter | Description
x | Required. A number

Example

In this example we will round different numbers with the round() method:

<script type="text/javascript">
document.write(Math.round(0.60) + "<br />")
document.write(Math.round(0.50) + "<br />")
document.write(Math.round(0.49) + "<br />")
document.write(Math.round(-4.40) + "<br />")
document.write(Math.round(-4.60))
</script>

The output of the code above will be:

1
1
0
-4
-5


The search() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The search() method

Definition and Usage

The search() method is used to search a string for a specified value.

Syntax

stringObject.search(searchstring)

Parameter | Description
searchstring | Required. The value to search for in a string. To perform a case-insensitive search add an 'i' flag

Tips and Notes

Note: search() is case sensitive.

Note: The search() method returns the position of the specified value in the string. If no match was found it returns -1.

Example 1 - Standard Search

In the following example we will search for the word "W3Schools":

<script type="text/javascript">
var str="Visit W3Schools!"
document.write(str.search(/W3Schools/))
</script>

The output of the code above will be:

6

Note: In the following example the word "w3schools" will not be found (because the search() method is case sensitive):

<script type="text/javascript">
var str="Visit W3Schools!"
document.write(str.search(/w3schools/))
</script>

The output of the code above will be:

-1

Example 2 - Case-insensitive Search

In the following example we will perform a case-insensitive search:

<script type="text/javascript">
var str="Visit W3Schools!"
document.write(str.search(/w3schools/i))
</script>

The output of the code above will be:

6


The setDate() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setDate() method

Definition and Usage

The setDate() method is used to set the day of the month.

Syntax

dateObject.setDate(day)

Parameter | Description
day | Required. A numeric value (from 1 to 31) that represents a day in a month

Tips and Notes

Note: This method is always used in conjunction with a Date object.

Example

In this example we set the day of the current month to 15 with the setDate() method:

<script type="text/javascript">
var d = new Date()
d.setDate(15)
document.write(d)
</script>

The output of the code above will be:

Sat Oct 15 2005 08:50:23 GMT-0500 (Central Daylight Time)


The setFullYear() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setFullYear() method

Definition and Usage

The setFullYear() method is used to set the year.

Syntax

dateObject.setFullYear(year,month,day)

Parameter | Description
year | Required. A four-digit value representing the year
month | Optional. A numeric value between 0 and 11 representing the month
day | Optional. A numeric value between 1 and 31 representing the date

Tips and Notes

Note: This method is always used in conjunction with a Date object.

Example

In this example we set the year to 1992 with the setFullYear() method:

<script type="text/javascript">
var d = new Date()
d.setFullYear(1992)
document.write(d)
</script>

The output of the code above will be:

Sat Oct 24 1992 08:52:19 GMT-0500 (Central Daylight Time)

Example 2

In this example we set the date to November 3, 1992 with the setFullYear() method:

<script type="text/javascript">
var d = new Date()
d.setFullYear(1992,10,3)
document.write(d)
</script>

The output of the code above will be:

Tue Nov 03 1992 08:52:19 GMT-0600 (Central Standard Time)


The setHours() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setHours() method

Definition and Usage

The setHours() method is used to set the hour of a specified time.

Syntax

dateObject.setHours(hour,min,sec,millisec)

Parameter | Description
hour | Required. A numeric value between 0 and 23 representing the hour
min | Optional. A numeric value between 0 and 59 representing the minutes
sec | Optional. A numeric value between 0 and 59 representing the seconds
millisec | Optional. A numeric value between 0 and 999 representing the milliseconds

Tips and Notes

Note: If one of the parameters above is specified with a one-digit number, JavaScript adds one or two leading zeros in the result.

Note: This method is always used in conjunction with a Date object.

Example

In this example we set the hour of the current time to 15, with the setHours() method:

<script type="text/javascript">
var d = new Date()
d.setHours(15)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 15:55:01 GMT-0500 (Central Daylight Time)

Example

In this example we set the time to 15:35:01, with the setHours() method:

<script type="text/javascript">
var d = new Date()
d.setHours(15,35,1)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 15:35:01 GMT-0500 (Central Daylight Time)


The setMilliseconds() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setMilliseconds() method

Definition and Usage

The setMilliseconds() method is used to set the milliseconds of a specified time.

Syntax

dateObject.setMilliseconds(millisec)

Parameter | Description
millisec | Required. A numeric value between 0 and 999 representing the milliseconds

Tips and Notes

Note: If the parameter above is specified with a one-digit or two-digit number, JavaScript adds one or two leading zeros in the result.

Note: This method is always used in conjunction with a Date object.

Example

In this example we set the milliseconds of the current time to 001, with the setMilliseconds() method:

<script type="text/javascript">
var d = new Date()
d.setMilliseconds(1)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 08:57:19 GMT-0500 (Central Daylight Time)


The setMinutes() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setMinutes() method

Definition and Usage

The setMinutes() method is used to set the minutes of a specified time.

Syntax

dateObject.setMinutes(min,sec,millisec)

Parameter | Description
min | Required. A numeric value between 0 and 59 representing the minutes
sec | Optional. A numeric value between 0 and 59 representing the seconds
millisec | Optional. A numeric value between 0 and 999 representing the milliseconds

Tips and Notes

Note: If one of the parameters above is specified with a one-digit number, JavaScript adds one or two leading zeros in the result.

Note: This method is always used in conjunction with a Date object.

Example

In this example we set the minutes of the current time to 01, with the setMinutes() method:

<script type="text/javascript">
var d = new Date()
d.setMinutes(1)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 08:01:47 GMT-0500 (Central Daylight Time)


The setMonth() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setMonth() method

Definition and Usage

The setMonth() method is used to set the month.

Syntax

dateObject.setMonth(month,day)

Parameter | Description
month | Required. A numeric value between 0 and 11 representing the month
day | Optional. A numeric value between 1 and 31 representing the day

Tips and Notes

Note: The value set by setMonth() is a number between 0 and 11. January is 0, February is 1 and so on.

Note: This method is always used in conjunction with a Date object.

Example

In this example we set the month to 0 (January) with the setMonth() method:

<script type="text/javascript">
var d=new Date()
d.setMonth(0)
document.write(d)
</script>

The output of the code above will be:

Mon Jan 24 2005 08:51:15 GMT-0600 (Central Standard Time)

Example 2

In this example we set the month to 0 (January) and the day to 20 with the setMonth() method:

<script type="text/javascript">
var d=new Date()
d.setMonth(0,20)
document.write(d)
</script>

The output of the code above will be:

Thu Jan 20 2005 08:51:15 GMT-0600 (Central Standard Time)


The setSeconds() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setSeconds() method

Definition and Usage

The setSeconds() method is used to set the seconds of a specified time.

Syntax

dateObject.setSeconds(sec,millisec)

Parameter | Description
sec | Required. A numeric value between 0 and 59 representing the seconds
millisec | Optional. A numeric value between 0 and 999 representing the milliseconds

Tips and Notes

Note: If one of the parameters above is specified with a one-digit number, JavaScript adds one or two leading zeros in the result.

Note: This method is always used in conjunction with a Date object.

Example

In this example we set the seconds of the current time to 01, with the setSeconds() method:

<script type="text/javascript">
var d = new Date()
d.setSeconds(1)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 08:56:01 GMT-0500 (Central Daylight Time)


The setTime() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setTime() method

Definition and Usage

The setTime() method is used to calculate a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970.

Syntax

dateObject.setTime(millisec)

Parameter | Description
millisec | Required. A numeric value representing the milliseconds since midnight January 1, 1970. Can be a negative number

Tips and Notes

Note: This method is always used in conjunction with a Date object.

Example

In this example we will add 77771564221 milliseconds to 1970/01/01 and display the new date and time:

<script type="text/javascript">
var d = new Date()
d.setTime(77771564221)
document.write(d)
</script>

The output of the code above will be:

Mon Jun 19 05:12:44 UTC+0200 1972

Example

In this example we will subtract 77771564221 milliseconds from 1970/01/01 and display the new date and time:

<script type="text/javascript">
var d = new Date()
d.setTime(-77771564221)
document.write(d)
</script>

The output of the code above will be:

Sat Jul 15 22:47:15 UTC+0200 1967


The setUTCDate() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setUTCDate() method

Definition and Usage

The setUTCDate() method is used to set the day of the month according to Universal Coordinated Time (UTC).

Syntax

dateObject.setUTCDate(day)

Parameter | Description
day | Required. A numeric value (from 1 to 31) that represents a day in a month

Tips and Notes

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we set the day of the current month to 15 with the setUTCDate() method:

<script type="text/javascript">
var d = new Date()
d.setUTCDate(15)
document.write(d)
</script>

The output of the code above will be:

Sat Oct 15 2005 08:58:28 GMT-0500 (Central Daylight Time)


The setUTCFullYear() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setUTCFullYear() method

Definition and Usage

The setUTCFullYear() method is used to set the year according to Universal Coordinated Time (UTC).

Syntax

dateObject.setUTCFullYear(year,month,day)

Parameter | Description
year | Required. A four-digit value representing the year
month | Optional. A numeric value between 0 and 11 representing the month
day | Optional. A numeric value between 1 and 31 representing the date

Tips and Notes

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we set the year to 1992 with the setUTCFullYear() method:

<script type="text/javascript">
var d = new Date()
d.setUTCFullYear(1992)
document.write(d)
</script>

The output of the code above will be:

Sat Oct 24 1992 08:59:43 GMT-0500 (Central Daylight Time)

Example 2

In this example we set the date to November 3, 1992 with the setUTCFullYear() method:

<script type="text/javascript">
var d = new Date()
d.setUTCFullYear(1992,10,3)
document.write(d)
</script>

The output of the code above will be:

Tue Nov 03 1992 07:59:43 GMT-0600 (Central Standard Time)


The setUTCHours() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setUTCHours() method

Definition and Usage

The setHours() method is used to set the hour of a specified time according to Universal Coordinated Time (UTC).

Syntax

dateObject.setUTCHours(hour,min,sec,millisec)

Parameter | Description
hour | Required. A numeric value between 0 and 23 representing the hour
min | Optional. A numeric value between 0 and 59 representing the minutes
sec | Optional. A numeric value between 0 and 59 representing the seconds
millisec | Optional. A numeric value between 0 and 999 representing the milliseconds

Tips and Notes

Note: If one of the parameters above is specified with a one-digit number, JavaScript adds one or two leading zeros in the result.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we set the hour of the current time to 15, with the setUTCHours() method:

<script type="text/javascript">
var d = new Date()
d.setUTCHours(15)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 10:00:45 GMT-0500 (Central Daylight Time)

Example

In this example we set the time to 15:35:01, with the setUTCHours() method:

<script type="text/javascript">
var d = new Date()
d.setUTCHours(15,35,1)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 10:35:01 GMT-0500 (Central Daylight Time)


The setUTCMilliseconds() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setUTCMilliseconds() method

Definition and Usage

The setUTCMilliseconds() method is used to set the milliseconds of a specified time according to Universal Coordinated Time (UTC).

Syntax

dateObject.setUTCMilliseconds(millisec)

Parameter | Description
millisec | Required. A numeric value between 0 and 999 representing the milliseconds

Tips and Notes

Note: If the parameter above is specified with a one-digit or two-digit number, JavaScript adds one or two leading zeros in the result.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we set the milliseconds of the current time to 001, with the setUTCMilliseconds() method:

<script type="text/javascript">
var d = new Date()
d.setUTCMilliseconds(1)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 09:02:55 GMT-0500 (Central Daylight Time)


The setUTCMinutes() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setUTCMinutes() method

Definition and Usage

The setUTCMinutes() method is used to set the minutes of a specified time according to Universal Coordinated Time (UTC).

Syntax

dateObject.setUTCMinutes(min,sec,millisec)

Parameter | Description
min | Required. A numeric value between 0 and 59 representing the minutes
sec | Optional. A numeric value between 0 and 59 representing the seconds
millisec | Optional. A numeric value between 0 and 999 representing the milliseconds

Tips and Notes

Note: If one of the parameters above is specified with a one-digit number, JavaScript adds one or two leading zeros in the result.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we set the minutes of the current time to 01, with the setUTCMinutes() method:

<script type="text/javascript">
var d = new Date()
d.setUTCMinutes(1)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 09:01:43 GMT-0500 (Central Daylight Time)


The setUTCMonth() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setUTCMonth() method

Definition and Usage

The setUTCMonth() method is used to set the month according to Universal Coordinated Time (UTC).

Syntax

dateObject.setUTCMonth(month,day)

Parameter | Description
month | Required. A numeric value between 0 and 11 representing the month
dayn | Optional. A numeric value between 1 and 31 representing the day

Tips and Notes

Note: The value set by setUTCMonth() is a number between 0 and 11. January is 0, February is 1 and so on.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we set the month to 0 (January) with the setUTCMonth() method:

<script type="text/javascript">
var d=new Date()
d.setUTCMonth(0)
document.write(d)
</script>

The output of the code above will be:

Mon Jan 24 2005 07:58:54 GMT-0600 (Central Standard Time)

Example 2

In this example we set the month to 0 (January) and the day to 20 with the setUTCMonth() method:

<script type="text/javascript">
var d=new Date()
d.setUTCMonth(0,20)
document.write(d)
</script>

The output of the code above will be:

Thu Jan 20 2005 07:58:54 GMT-0600 (Central Standard Time)


The setUTCSeconds() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setUTCSeconds() method

Definition and Usage

The setSeconds() method is used to set the seconds of a specified time according to Universal Coordinated Time (UTC).

Syntax

dateObject.setUTCSeconds(sec,millisec)

Parameter | Description
sec | Required. A numeric value between 0 and 59 representing the seconds
millisec | Optional. A numeric value between 0 and 999 representing the milliseconds

Tips and Notes

Note: If one of the parameters above is specified with a one-digit number, JavaScript adds one or two leading zeros in the result.

Note: This method is always used in conjunction with a Date object.

Tip: The Universal Coordinated Time (UTC) is the time set by the World Time Standard.

Example

In this example we set the seconds of the current time to 01, with the setUTCSeconds() method:

<script type="text/javascript">
var d = new Date()
d.setUTCSeconds(1)
document.write(d)
</script>

The output of the code above will be:

Mon Oct 24 2005 09:02:01 GMT-0500 (Central Daylight Time)


The setYear() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The setYear() method

Definition and Usage

The setYear() method is used to set the year.

Syntax

dateObject.setYear(year)

Parameter | Description
year | Required. A two or four digit number that indicates the year

Tips and Notes

Note: If the year parameter is a two-digit number, like setYear(91), it will be perceived as 1991. To specify a year before 1900 or after 1999, always use four digits!

Note: This method is always used in conjunction with a Date object.

Important: The setYear() method should no longer be used. Use the setFullYear() method instead!!

Example

In this example we set the year to 1891 with the setYear() method:

<script type="text/javascript">
var d = new Date()
d.setYear(1891)
document.write(d)
</script>

The output of the code above will be:

Sat Oct 24 1891 08:53:14 GMT-0500 (Central Daylight Time)


The shift() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The shift() method

Definition and Usage

The shift() method is used to remove and return the first element of an array.

Syntax

arrayObject.shift()

Tips and Notes

Note: This method changes the length of the array.

Tip: To remove and return the last element of an array, use the pop() method.

Example

In this example we will create an array, and then remove the first element of the array. Note that this will also change the length of the array:

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
document.write(arr + "<br />")
document.write(arr.shift() + "<br />")
document.write(arr)
</script>

The output of the code above will be:

Jani,Hege,Stale
Jani
Hege,Stale


The sin() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The sin() method

Definition and Usage

The sin() method returns the sine of a number.

Syntax

Math.sin(x)

Parameter | Description
x | Required. A number

Tips and Notes

Note: The sin() method returns a numeric value between -1 and 1, which represents the sine of the argument.

Example

In the following example we will return the sine of different numbers:

<script type="text/javascript">
document.write(Math.sin(3) + "<br />")
document.write(Math.sin(-3) + "<br />")
document.write(Math.sin(0) + "<br />")
document.write(Math.sin(Math.PI) + "<br />")
document.write(Math.sin(Math.PI/2))
</script>

The output of the code above will be:

0.1411200080598672
-0.1411200080598672
0
1.2246063538223772e-16
1


The slice() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The slice() method

Definition and Usage

The slice() method returns selected elements from an existing array.

Syntax

arrayObject.slice(start,end)

Parameter | Description
start | Required. Specify where to start the selection. Must be a number
end | Optional. Specify where to end the selection. Must be a number

Tips and Notes

Tip: You can use negative numbers to select from the end of the array.

Note: If end is not specified, slice() selects all elements from the specified start position and to the end of the array.

Example

In this example we will create an array, and then display selected elements from it:

<script type="text/javascript">

var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"

document.write(arr + "<br />")
document.write(arr.slice(1) + "<br />")
document.write(arr)

</script>

The output of the code above will be:

Jani,Hege,Stale
Hege,Stale
Jani,Hege,Stale

Example

In this example we will create an array, and then display selected elements from it:

<script type="text/javascript">

var arr = new Array(6)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
arr[3] = "Kai Jim"
arr[4] = "Borge"
arr[5] = "Tove"

document.write(arr + "<br />")
document.write(arr.slice(2,4) + "<br />")
document.write(arr)

</script>

The output of the code above will be:

Jani,Hege,Stale,Kai Jim,Borge,Tove
Stale,Kai Jim
Jani,Hege,Stale,Kai Jim,Borge,Tove


The slice() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The slice() method

Definition and Usage

The slice() method extracts a part of a string and returns the extracted part in a new string.

Syntax

stringObject.slice(start,end)

Parameter | Description
start | Required. Specify where to start the selection. Must be a number
end | Optional. Specify where to end the selection. Must be a number

Tips and Notes

Tip: You can use negative index numbers to select from the end of the string.

Note: If end is not specified, slice() selects all characters from the specified start position and to the end of the string.

Example 1

In this example we will extract all characters from a string, starting at position 6:

<script type="text/javascript">
var str="Hello happy world!"
document.write(str.slice(6))
</script>

The output of the code above will be:

happy world!

Example 2

In this example we will extract all the characters from position 6 to position 11:

<script type="text/javascript">
var str="Hello happy world!"
document.write(str.slice(6,11))
</script>

The output of the code above will be:

happy


The small() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The small() method

Definition and Usage

The small() method is used to display a string in a small font.

Syntax

stringObject.small()

Example

In this example "Hello world!" will be displayed in a small font:

<script type="text/javascript">
var str="Hello world!"
document.write(str.small())
</script>


The sort() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The sort() method

Definition and Usage

The sort() method is used to sort the elements of an array.

Syntax

arrayObject.sort(sortby)

Parameter | Description
sortby | Optional. Specifies the sort order. Must be a function

Tips and Notes

Note: The sort() method will sort the elements alphabetically by default. However, this means that numbers will not be sorted correctly (40 comes before 5). To sort numbers, you must create a function that compare numbers.

Note: After using the sort() method, the array is changed.

Example

In this example we will create an array and sort it alphabetically:

<script type="text/javascript">
var arr = new Array(6)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
arr[3] = "Kai Jim"
arr[4] = "Borge"
arr[5] = "Tove"
document.write(arr + "<br />")
document.write(arr.sort())
</script>

The output of the code above will be:

Jani,Hege,Stale,Kai Jim,Borge,Tove
Borge,Hege,Jani,Kai Jim,Stale,Tove

Example

In this example we will create an array containing numbers and sort it:

<script type="text/javascript">
var arr = new Array(6)
arr[0] = "10"
arr[1] = "5"
arr[2] = "40"
arr[3] = "25"
arr[4] = "1000"
arr[5] = "1"
document.write(arr + "<br />")
document.write(arr.sort())
</script>

The output of the code above will be:

10,5,40,25,1000,1
1,10,1000,25,40,5

Note that the numbers above are NOT sorted correctly (by numeric value). To solve this problem, we must add a function that handles this problem:

<script type="text/javascript">
function sortNumber(a,b)
{
return a - b
}
var arr = new Array(6)
arr[0] = "10"
arr[1] = "5"
arr[2] = "40"
arr[3] = "25"
arr[4] = "1000"
arr[5] = "1"
document.write(arr + "<br />")
document.write(arr.sort(sortNumber))
</script>

The output of the code above will be:

10,5,40,25,1000,1
1,5,10,25,40,1000


The splice() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The splice() method

Definition and Usage

The splice() method is used to remove and add new elements to an array.

Syntax

arrayObject.splice(index,howmany,element1,.....,elementX)

Parameter | Description
index | Required. Specify where to add/remove elements. Must be a number
howmany | Required Specify how many elements should be removed. Must be a number, but can be "0"
element1 | Optional. Specify a new element to add to the array
elementX | Optional. Several elements can be added

Example

In this example we will create an array and add an element to it:

<script type="text/javascript">
var arr = new Array(5)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
arr[3] = "Kai Jim"
arr[4] = "Borge"
document.write(arr + "<br />")
arr.splice(2,0,"Lene")
document.write(arr + "<br />")
</script>

The output of the code above will be:

Jani,Hege,Stale,Kai Jim,Borge
Jani,Hege,Lene,Stale,Kai Jim,Borge

Example

In this example we will remove the element at index 2 ("Stale"), and add a new element ("Tove") there instead:

<script type="text/javascript">
var arr = new Array(5)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
arr[3] = "Kai Jim"
arr[4] = "Borge"
document.write(arr + "<br />")
arr.splice(2,1,"Tove")
document.write(arr)
</script>

The output of the code above will be:

Jani,Hege,Stale,Kai Jim,Borge
Jani,Hege,Tove,Kai Jim,Borge

Example

In this example we will remove three elements starting at index 2 ("Stale"), and add a new element ("Tove") there instead:

<script type="text/javascript">
var arr = new Array(5)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
arr[3] = "Kai Jim"
arr[4] = "Borge"
document.write(arr + "<br />")
arr.splice(2,3,"Tove")
document.write(arr)
</script>

The output of the code above will be:

Jani,Hege,Stale,Kai Jim,Borge
Jani,Hege,Tove


The split() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The split() method

Definition and Usage

The split() method is used to split a string into an array of strings.

Syntax

stringObject.split(separator, howmany)

Parameter | Description
separator | Required. Specifies the character, regular expression, or substring that is used to determine where to split the string
howmany | Optional. Specify how many times split should occur. Must be a numeric value

Tips and Notes

Note: If an empty string ("") is used as the separator, the string is split between each character.

Example

In this example we will split up a string in different ways:

<script type="text/javascript">
var str="How are you doing today?"
document.write(str.split(" ") + "<br />")
document.write(str.split("") + "<br />")
document.write(str.split(" ",3))
</script>

The output of the code above will be:

How,are,you,doing,today?
H,o,w, ,a,r,e, ,y,o,u, ,d,o,i,n,g, ,t,o,d,a,y,?
How,are,you


The sqrt() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The sqrt() method

Definition and Usage

The sqrt() method returns the square root of a number.

Syntax

Math.sqrt(x)

Parameter | Description
x | Required. A number

Tips and Notes

Note: The sqrt() method will return NaN if the parameter x is a negative number.

Example

In this example we will get the square root of different numbers:

<script type="text/javascript">
document.write(Math.sqrt(0) + "<br />")
document.write(Math.sqrt(1) + "<br />")
document.write(Math.sqrt(9) + "<br />")
document.write(Math.sqrt(0.64) + "<br />")
document.write(Math.sqrt(-9))
</script>

The output of the code above will be:

0
1
3
0.8
NaN


The strike() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The strike() method

Definition and Usage

The strike() method is used to display a string with a strikethrough.

Syntax

stringObject.strike()

Example

In this example "Hello world!" will be displayed with a line trough it:

<script type="text/javascript">
var str="Hello world!"
document.write(str.strike())
</script>


The String() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The String() Function

Definition and Usage

The String() function converts the value of an object to a string.

Syntax

String(object)

Parameter | Description
object | Required. A JavaScript object

Tips and Notes

Note: The String() function returns the same value as toString() of the individual objects.

Example

In this example we will try to convert different objects to strings:

<script type="text/javascript">
var test1= new Boolean(1)
var test2= new Boolean(0)
var test3= new Boolean(true)
var test4= new Boolean(false)
var test5= new Date()
var test6= new String("999 888")
var test7=12345

document.write(String(test1)+ "<br />")
document.write(String(test2)+ "<br />")
document.write(String(test3)+ "<br />")
document.write(String(test4)+ "<br />")
document.write(String(test5)+ "<br />")
document.write(String(test6)+ "<br />")
document.write(String(test7)+ "<br />")
</script>

The output of the code above will be:

true
false
true
false
Mon Oct 24 2005 09:16:05 GMT-0500 (Central Daylight Time)
999 888
12345


The sub() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The sub() method

Definition and Usage

The sub() method is used to display a string as subscript.

Syntax

stringObject.sub()

Example

In this example "Hello world!" will be displayed in subscript:

<script type="text/javascript">
var str="Hello world!"
document.write(str.sub())
</script>


The substr() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The substr() method

Definition and Usage

The substr() method extracts a specified number of characters in a string, from a start index.

Syntax

stringObject.substr(start,length)

Parameter | Description
start | Required.Where to start the extraction. Must be a numeric value
length | Optional. How many characters to extract. Must be a numeric value.

Tips and Notes

Note: To extract characters from the end of the string, use a negative start number.

Note: The start index starts at 0.

Note: If the length parameter is omitted, this method extracts to the end of the string.

Example

In this example we will use substr() to extract some characters from a string:

<script type="text/javascript">
var str="Hello world!"
document.write(str.substr(3))
</script>

The output of the code above will be:

lo world!

Example

In this example we will use substr() to extract some characters from a string:

<script type="text/javascript">
var str="Hello world!"
document.write(str.substr(3,7))
</script>

The output of the code above will be:

lo worl


The substring() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The substring() method

Definition and Usage

The substring() method extracts the characters in a string between two specified indices.

Syntax

stringObject.substring(start,stop)

Parameter | Description
start | Required. Where to start the extraction. Must be a numeric value
stop | Optional. Where to stop the extraction. Must be a numeric value

Tips and Notes

Note: To extract characters from the end of the string, use a negative start number.

Note: The start index starts at 0.

Note: If the stop parameter is omitted, this method extracts to the end of the string.

Example

In this example we will use substring() to extract some characters from a string:

<script type="text/javascript">
var str="Hello world!"
document.write(str.substring(3))
</script>

The output of the code above will be:

lo world!

Example

In this example we will use substring() to extract some characters from a string:

<script type="text/javascript">
var str="Hello world!"
document.write(str.substring(3,7))
</script>

The output of the code above will be:

lo w


The sup() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The sup() method

Definition and Usage

The sup() method is used to display a string as superscript.

Syntax

stringObject.sup()

Example

In this example "Hello world!" will be displayed in superscript:

<script type="text/javascript">
var str="Hello world!"
document.write(str.sup())
</script>


The tan() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The tan() method

Definition and Usage

The tan() method returns a number that represents the tangent of an angle.

Syntax

Math.tan(x)

Parameter | Description
x | Required. A number

Example

In this example we will get the tangent of different numbers:

<script type="text/javascript">
document.write(Math.tan(0.50) + "<br />")
document.write(Math.tan(-0.50) + "<br />")
document.write(Math.tan(5) + "<br />")
document.write(Math.tan(10) + "<br />")
document.write(Math.tan(-5) + "<br />")
document.write(Math.tan(-10))
</script>

The output of the code above will be:

0.5463024898437905
-0.5463024898437905
-3.380515006246586
0.6483608274590866
3.380515006246586
-0.6483608274590866


The toGMTString() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The toGMTString() method

Definition and Usage

The toGMTString() method converts a Date object, according to Greenwich Mean Time (GMT), to a string and returns the result.

Syntax

dateObject.toGMTString()

Tips and Notes

Note: This method should no longer be used! Use the toUTCString() method instead!!

Example

In the example below we will convert today's date (according to GMT) to a string:

<script type="text/javascript">
var d = new Date()
document.write (d.toGMTString())
</script>

The output of the code above will be:

Mon, 24 Oct 2005 14:04:27 GMT

Example 2

In the example below we will convert a specific date (according to GMT) to a string:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.toGMTString())
</script>

The output of the code above will be:

Thu, 21 Jul 1983 06:15:00 GMT


The toLocaleString() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The toLocaleString() method

Definition and Usage

The toLocaleString() method converts a Date object, according to local time, to a string and returns the result.

Syntax

dateObject.toLocaleString()

Example

In the example below we will convert today's date (according to local time) to a string:

<script type="text/javascript">
var d = new Date()
document.write(d.toLocaleString())
</script>

The output of the code above will be:

Monday, October 24, 2005 9:06:06 AM

Example 2

In the example below we will convert a specific date (according to local time) to a string:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.toLocaleString())
</script>

The output of the code above will be:

Thursday, July 21, 1983 1:15:00 AM


The toLowerCase() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The toLowerCase() method

Definition and Usage

The toLowerCase() method is used to display a string in lowercase letters.

Syntax

stringObject.toLowerCase()

Example

In this example "Hello world!" will be displayed in lower case letters:

<script type="text/javascript">
var str="Hello World!"
document.write(str.toLowerCase())
</script>


The toSource() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The toSource() Method

Definition and Usage

The toSource() method represents the source code of an object.

Syntax

object.toSource()

Tips and Notes

Note: This method does not work in Internet Explorer!

Example

In this example we will show how to use the toSource() method:

<script type="text/javascript">
function employee(name,jobtitle,born)
{
this.name=name
this.jobtitle=jobtitle
this.born=born
}
var fred=new employee("Fred Flintstone","Caveman",1970)
document.write(fred.toSource())
</script>

The output of the code above will be:

({name:"Fred Flintstone", jobtitle:"Caveman", born:1970})


The toString() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The toString() method

Definition and Usage

The toString() method converts an array to a string and returns the result.

Syntax

arrayObject.toString()

Tips and Notes

Note: The elements in the array will be separated with commas.

Example

In this example we will create an array and convert it to a string:

<script type="text/javascript">
var arr = new Array(3)
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
document.write(arr.toString())
</script>

The output of the code above will be:

Jani,Hege,Stale


The toString() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The toString() method

Definition and Usage

The toString() method converts a Boolean value to a string and returns the result.

Syntax

booleanObject.toString()

Tips and Notes

Note: This method is called by JavaScript automatically whenever a Boolean object is used in a situation requiring a string.

Example

In this example we will create a Boolean and then convert it to a string:

<script type="text/javascript">
var boo = new Boolean(true)
document.write(boo.toString())
</script>

The output of the code above will be:

true


The toString() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The toString() method

Definition and Usage

The toString() method converts a Date object to a string and returns the result.

Syntax

dateObject.toString()

Example

In this example we will convert today's date to a string:

<script type="text/javascript">
var d = new Date()
document.write (d.toString())
</script>

The output of the code above will be:

Mon Oct 24 2005 09:03:41 GMT-0500 (Central Daylight Time)


The toUpperCase() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The toUpperCase() method

Definition and Usage

The toUpperCase() method is used to display a string in uppercase letters.

Syntax

stringObject.toUpperCase()

Example

In this example "Hello world!" will be displayed in upper case letters:

<script type="text/javascript">
var str="Hello world!"
document.write(str.toUpperCase())
</script>


The toUTCString() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The toUTCString() method

Definition and Usage

The toUTCString() method converts a Date object, according to Universal Coordinated Time (UTC), to a string and returns the result.

Syntax

dateObject.toUTCString()

Example

In the example below we will convert today's date (according to UTC) to a string:

<script type="text/javascript">
var d = new Date()
document.write (d.toUTCString())
</script>

The output of the code above will be:

Mon, 24 Oct 2005 14:05:24 GMT

Example 2

In the example below we will convert a specific date (according to UTC) to a string:

<script type="text/javascript">
var born = new Date("July 21, 1983 01:15:00")
document.write(born.toUTCString())
</script>

The output of the code above will be:

Thu, 21 Jul 1983 06:15:00 GMT


The undefined Property

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The undefined Property

Definition and Usage

The undefined property indicates that a variable has not been assigned a value.

Syntax

undefined

Example

In this example we will test two variables to find out if one of them is undefined:

<script type="text/javascript">
var t1=""
var t2
if (t1==undefined) {document.write("t1 is undefined")}
if (t2==undefined) {document.write("t2 is undefined")}
</script>

The output of the code above will be:

t2 is undefined


The unescape() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The unescape() Function

Definition and Usage

The unescape() function decodes a string encoded with escape().

Syntax

unescape(string)

Parameter | Description
string | Required. The string to be decoded

Tips and Notes

Note: The escape() and unescape() functions should not be used to encode or decode URIs. Use encodeURI() and decodeURI() functions instead!

Example

In this example we first encode the strings with the escape() function, and then decode them with the unescape() function:

<script type="text/javascript">
var test1="Visit W3Schools!"
var test2=".:&%#"
document.write (escape(test1)) + "<br />")
document.write (escape(test2)) + "<br />")
document.write(unescape(test1) + "<br />")
document.write(unescape(test2) + "<br />")
</script>

The output of the code above will be:

Visit%20W3Schools%21
.%3A%26%25%23
Visit W3Schools!
.:&%#


The unshift() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The unshift() method

Definition and Usage

The unshift() method adds one or more elements to the beginning of an array and returns the new length.

Syntax

arrayObject.unshift(newelement1,newelement2,....,newelementX)

Parameter | Description
newelement1 | Required. The first element to add to the array
newelement2 | Optional. The second element to add to the array
newelementX | Optional. Several elements may be added

Tips and Notes

Note: This method changes the length of the array.

Note: The unshift() method does not work properly in Internet Explorer!

Tip: To add one or more elements to the end of an array, use the push() method.

Example

In this example we will create an array, add an element to the beginning of the array and then return the new length:

<script type="text/javascript">
var arr = new Array()
arr[0] = "Jani"
arr[1] = "Hege"
arr[2] = "Stale"
document.write(arr + "<br />")
document.write(arr.unshift("Kai Jim") + "<br />")
document.write(arr)
</script>

The output of the code above will be:

Jani,Hege,Stale
4
Kai Jim,Jani,Hege,Stale


The UTC() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The UTC() method

Definition and Usage

The UTC() method takes a date and returns the number of milliseconds since midnight of January 1, 1970 according to universal time.

Syntax

Date.UTC(year,month,day,hours,minutes,seconds,ms)

Parameter | Description
year | Required. A four digit number representing the year
month | Required. An integer between 0 and 11 representing the month
day | Required. An integer between 1 and 31 representing the date
hours | Optional. An integer between 0 and 23 representing the hour
minutes | Optional. An integer between 0 and 59 representing the minutes
seconds | Optional. An integer between 0 and 59 representing the seconds
ms | Optional. An integer between 0 and 999 representing the milliseconds

Example

In this example we will get how many milliseconds there are from 1970/01/01 to 2005/07/08 according to universal time:

<script type="text/javascript">
var d = Date.UTC(2005,7,8)
document.write(d)
</script>

The output of the code above will be:

1123459200000

Example 2

Now we will convert the output from the example above into years:

<script type="text/javascript">
var minutes = 1000 * 60
var hours = minutes * 60
var days = hours * 24
var years = days * 365
var t = Date.UTC(2005,7,8)
var y = t/years
document.write("It's been: " + y + " years from 1970/01/01")
document.write(" to 2005/07/08!")
</script>

The output of the code above will be:

It's been: 35.62465753424657 years from 1970/01/01 to 2005/07/08!


The valueOf() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The valueOf() method

Definition and Usage

The valueOf() method returns the primitive value of an Array object.

The primitive value is inherited by all objects descended from the Array object.

The valueOf() method is usually called automatically by JavaScript behind the scenes and not explicitly in code.

Syntax

arrayObject.valueOf()


The valueOf() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The valueOf() method

Definition and Usage

The valueOf() method returns the primitive value of a Boolean object.

Syntax

booleanObject.valueOf()

Example

In this example we will create a Boolean object and use valueOf() the get the primitive value of it:

<script type="text/javascript">
var boo = new Boolean(false)
document.write(boo.valueOf())
</script>

The output of the code above will be:

false


The valueOf() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The valueOf() method

Definition and Usage

The valueOf() method returns the primitive value of a Date object.

The primitive value is inherited by all objects descended from the Date object.

The valueOf() method is usually called automatically by JavaScript behind the scenes and not explicitly in code.

Syntax

dateObject.valueOf()


The valueOf() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The valueOf() method

Definition and Usage

The valueOf() method returns the primitive value of a Math object.

The primitive value is inherited by all objects descended from the Math object.

The valueOf() method is usually called automatically by JavaScript behind the scenes and not explicitly in code.

Syntax

mathObject.valueOf()


The valueOf() method

JS Boolean
JS Date
JS Math
JS String
JS Functions
JS Events

DOM Objects
DOM Anchor
DOM Applet
DOM Area
DOM Base
DOM Basefont
DOM Body
DOM Button
DOM Checkbox
DOM Document
DOM Event
DOM FileUpload
DOM Form
DOM Frame
DOM Frameset
DOM Hidden
DOM History
DOM Iframe
DOM Image
DOM Link
DOM Location
DOM Meta
DOM Navigator
DOM Option
DOM Password
DOM Radio
DOM Reset
DOM Screen
DOM Select
DOM Style
DOM Submit
DOM Table
DOM TableData
DOM TableHeader
DOM TableRow
DOM Text
DOM Textarea
DOM Window

The valueOf() method

Definition and Usage

The valueOf() method returns the primitive value of a String object.

The primitive value is inherited by all objects descended from the String object.

The valueOf() method is usually called automatically by JavaScript behind the scenes and not explicitly in code.

Syntax

stringObject.valueOf()