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

Button Object

The button object 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.

The Button objects are stored in the elements array of the corresponding form. You can access a Button object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

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

N: Netscape (including Mozilla when N6 or higher), IE: Internet Explorer, W3C: World Wide Web Consortium (Internet Standard)

Properties

Syntax: object.property_name

Property Description N IE  W3C
accessKey Sets or returns the keyboard key to access the Button object   5 Yes
disabled Sets or returns whether or not the Button should be disabled   5 Yes
form Returns a reference to the form that contains the Button object 2 3 Yes
id Sets or returns the id of the button (In IE 4 this property is read-only)   4 No
name Sets or returns the name of the button 2 3 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" 3 4 Yes
value Sets or returns the text that is displayed on the button 2 3 Yes

Methods

Syntax: object.method_name()

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

Events

Syntax: object.event_name="someJavaScriptCode"

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