Home >Web Front-end >JS Tutorial >Detailed explanation of JavaScript document and window properties and methods

Detailed explanation of JavaScript document and window properties and methods

伊谢尔伦
伊谢尔伦Original
2017-07-26 10:58:501543browse

[document object]

This object is a property of the window and frames objects, and is a document displayed in the window or frame.

 Attributes

 alinkColor The color of the active link (ALINK)
 anchor An HTMI anchor point, created using the tag (the attribute itself is also an object)
 anchors array lists the array of document anchor objects (
) (this attribute itself is also an object)
bgColor The background color of the document (BGCOLOR)
Cookies are stored in the cookie.txt file A piece of information, which is an attribute of the document object
 fgColor The text color of the document (TEXT attribute in the tag)
Form A form (

) in the document (this attribute Itself is also an object)
Forms anay lists an array of form objects in the order in which they appear in the document (this property itself is also an object)
LastModified The last modification date of the document
linkColor The link to the document The color, that is, the LINK attribute in the tag (linking to a document that the user has not observed)
 link A
tag in the document (the attribute itself is also an object)
links array An array of link objects in the document, arranged in the order they appear in the document (the property itself is also an object)
Location The URL of the currently displayed document. The user cannot change document.location (because this is the location where the document is currently displayed). However, window.location can be changed (replacing the current document with another document) window.location itself is also an object, and document.location is not an object
referrer contains the URL of the linked document, and the user can click the link to reach the current document
Title The title of the document ((TITLE>)
vlinkColor The text color of the link pointing to the document that the user has observed, that is, the VLINK attribute of the tag

Method

clear Clear the contents of the specified document
Close Close the document stream
Open Open the document stream
Write Write the text into the document
Writeln Write the text into the document and end with a newline character

[window object]

It is a top-level object, not a property of another object, that is, the browser window

DefaultStatus Default. Status bar message
Document The currently displayed document (the property itself is also an object)
frame A frame in the window ((FRAME>) (the property itself is also an object)
frames array Lists the windows An array of frame objects, listed in the order in which these objects appear in the document (this attribute itself is also an object)
 history The history list of the window (this attribute itself is also an object)
 length The number of frames in the window
Location The complete (absolute) URL of the document displayed in the window (this property itself is also an object). Do not confuse it with document.location, which is the URL of the currently displayed document. The user can change window.location (use another one. document replaces the current document), but cannot change document.location (because this is the location where the document is currently displayed)
Name is the name given to the window when the window is opened
opener represents a script that uses window.open to open the current window The window in which it is located (this is a new attribute introduced in Netscape Navigator 3.0beta 3)
 parent is a synonym for the window containing the current frame. An attribute of the frame and window objects
self is a synonym for the current window or frame
status The message in the status bar
Top Synonyms for the topmost browser window containing the current frame
Window Synonyms for the current window or frame, the same as self

Methods

alert( ) Open an Alert message box
ClearTimeout() is used to terminate the work of the setTimeout method
close() Close the window
confirm() Opens a Confirm message box, the user can choose OK or Cancel, if the user clicks OK, this method returns true, click Cancel to return false
 blur() Move the focus from the specified window (this is a new method introduced in Netscape Navigator 3.0 beta 3)
Focus() Bring the specified window to Front desk (another new method)
open() Open a new window
prompt() Open a Prompt dialog box. The user can type text into the box and return the typed text to the script
setTimeout( ) Wait for a specified number of milliseconds, and then run the command event handler

Event handler

Onload() Triggered when the page is loaded
Onunload() Triggered when the page is closed

The above is the detailed content of Detailed explanation of JavaScript document and window properties and methods. For more information, please follow other related articles on the PHP Chinese website!