- JavaScript Tutorial
- How to make pop-up windows
- JavaScript Object Reference (1)
- JavaScript Object Reference (2)
- JavaScript Object Reference (3)
- JavaScript Object Reference (4)
- JavaScript Object Reference (5)
- JavaScript Object Reference (6)
- JavaScript Functions and Operators
|
JavaScript Object Reference (2)
The document Object
The document object reflects attributes of an HTML document in JavaScript.
Properties
- alinkColor
- The color of active links as a string or a hexadecimal triplet.
- anchors
- Array of anchor objects in the order they appear in the HTML document. Use anchors.length to get the number of anchors in a document.
- bgColor
- The color of the document's background.
- cookie
- A string value containing cookie values for the current document.
- fgColor
- The color of the document's foreground.
- forms
- Array of form objects in the order the forms appear in the HTML file. Use forms.length to get the number of forms in a document.
- lastModified
- String value containing the last date of modification of the document.
- linkColor
- The color of links as a string or a hexadecimal triplet.
- links
- Array of link objects in the order the hypertext links appear in the HTML document. Use links.length to get the number of links in a document.
- location
- A string containing the URL of the current document.
- referrer
- A string value containing the URL of the calling document when the user follows a link.
- title
- A string containing the title of the current document.
- vlinkColor
- The color of followed links as a string or a hexadecimal triplet.
Methods
- clear()
- Clears the document window.
- close()
- Closes the current output stream.
- open(mimeType)
- Opens a stream which allows write() and writeln() methods to write to the document window. mimeType is an optional string which specifies a document type supported by
JavaScript or a plug-in (i.e. text/html, image/gif, etc.).
- write()
- Writes text and HTML to the specified document.
- writeln()
- Writes text and HTML to the specified document followed by a newline character.
The form Object
The form object reflects an HTML form in JavaScript. Each HTML form in a document is reflected by a distinct instance of the form object.
Properties
- action
- A string value specifying the URL to which the form data is submitted.
- elements
- Array of objects for each form element in the order in which they appear in the form.
- encoding
- String containing the MIME encoding of the form as specified in the ENCTYPE attribute.
- method
- A string value containing the method of submission of form data to the server.
- target
- A string value containing the name of the window to which responses to a form are submitted.
Methods
- submit()
- Submits the form.
Event Handlers
- onSubmit
- Specifies JavaScript code to execute when the form is submitted. The code should return a true value to allow the form to be submitted. A false value prevents the form from being submitted.
The frame Object
The frame object reflects a frame window in JavaScript.
Properties
- frames
- An array of objects for each frame in a window. Frames appear in the array in the order in which they appear in the HTML source code.
- parent
- A string indicating the name of the window containing the frameset.
- self
- A alternative for the name of the current window.
- top
- An alternative for the name of the top-most window.
- window
- An alternative for the name of the current window.
Methods
- alert(message)
- Displays message in a dialog box.
- close()
- Closes the window.
- confirm(message)
- Displays message in a dialog box with OK and CANCEL buttons. Returns true or false based on the button clicked by the user.
- open(url,name,features)
- Opens url in a window named name. If name doesn't exist, a new window is created with that name. features is an optional string argument containing a list of features for the new window. The feature list contains any of the following name-value pairs separated by commas and without additional spaces:
toolbar=[yes,no,1,0]
Indicates if the window should have a toolbar
location=[yes,no,1,0]
Indicates if the window should have a location field
directories=[yes,no,1,0]
Indicates is the window should have directory buttons
status=[yes,no,1,0]
Indicates if the window should have a status bar
menubar=[yes,no,1,0]
Indicates if the window should have menus
scrollbars=[yes,no,1,0]
Indicates if the window should have scroll bars
resizable=[yes,no,1,0]
Indicates if the window should be resizable
width=pixels
Indicates the width of the window in pixels
height=pixels
Indicates the height of the window in pixels
- prompt(message,response)
- Displays message in a dialog box with a text entry field with the default value of response. The user's response in the text entry field is returned as a string.
- setTimeout(expression,time)
- Evaluates expression after time where time is a value in milliseconds. The time out can be named with the structure:
name = setTimeOut(expression,time)
- clearTimeout(name)
- Cancels the time out with the name name.
The hidden Object
The hidden object reflects a hidden field from an HTML form in JavaScript.
Properties
- name
- A string value containing the name of the hidden element.
- value
- A string value containing the value of hidden text element.
Previous | Contents | Next
|
|