JS window object details, JSwindow object details
I. Description
It is the largest object in JS. It describes a browser Window. Generally, When referencing its attributes and methods, you do not need to use "Window. XXX ". A framework page is also a window.
2. Window objects have the following attributes:
1. name of the window, which is connected by opening the window (<a target = "... ">) or frame page (<frame name = "... ">) or the open () method called by a window (see below. This attribute is generally not used.
2. status indicates the content displayed in the "status bar" below the window. By assigning values to status, you can change the display of the status bar.
3. opener usage: window. opener; return the window object that opens the window. Note: A window object is returned. If the window is not opened by another window, null is returned for this attribute in Netscape; "undefined" is returned for IE ). Undefined is equal to null to some extent. Note: undefined is not a JavaScript constant. If you attempt to use "undefined", "undefined" is returned.
4. self refers to the window itself, which returns the same object as the window object. The most common is "self. close () ", placed in the <a> tag:" <a href = "javascript: self. close () "> close Window </a> ".
5. parent returns the frame Page Object of the window.
6. The top returned frame page Objects occupying the top of the entire browser window.
3. Window objects can be implemented using the following methods:
1. open (<URL string>, <window name string>, <parameter string> );
Note:
<URL string>: Describe the webpage opened in the window. If you leave it blank (''), no webpage is opened.
<Window name string>: the name of the window to be opened (window. name). You can use built-in names such as '_ top' and '_ blank. The name here is the same as the "target" attribute in "<a href ="... "target ="... ">.
<Parameter string>: Describes the appearance of the window to be opened. If you only need to open a normal window, leave this string blank (''). If you want to specify the appearance, write one or more parameters in the string, separated by commas.
For example, open a clean window of 400x100: open ('', '_ blank', 'width = 400, height = 100, menubar = no, toolbar = no, location = no, directories = no, status = no, scrollbars = yes, resizable = yes ')
Open () Parameters
Top = # number of records that exit from the top of the screen at the top of the window
Left = # number of records left when the left side of the window leaves the screen
Width = # window width
Height = # window height
Menubar =... Is there any menu in the window? The value is yes or no.
Toolbar =... does the window have a toolbar? The value is yes or no.
Location =... Is there an address bar in the window? The value is yes or no.
Directories =... whether there is a connection area in the window. The value is yes or no.
Scrollbars =... does the window have a scroll bar? The value is yes or no.
Status =... does the window have a status bar? values: yes or no
Resizable =... the window is not adjusted. The value is yes or no.
Note: The open () method has a return value, which is the window object it opens. For example
Var newWindow = open ('', '_ blank ');
In this way, a new window is assigned to the "newWindow" variable, and the window can be controlled through the "newWindow" variable.
2. close () to close an opened window.
3. blur () removes the focus from the window and changes the window to an "inactive window ".
4. focus () is the focus of the window and changes to "activity window ". However, in Windows 98, this method can only Flash the title bar of the window and the corresponding buttons on the taskbar, prompting the user that the window is trying to get the focus.
5. scrollTo () usage: [<window Object>.] scrollTo (x, y); enables the window to scroll from the (x, y) points in the upper left corner of the window to the upper left corner of the window.
6. Use scrollBy (): [<window Object>.] scrollBy (deltaX, deltaY); scroll the deltaX pixel to the right of the window and scroll down the deltaY pixel. If a negative value is obtained, it is rolled in the opposite direction.
7. resizeTo () usage: [<window Object>.] resizeTo (width, height); adjust the window size to width, width, and height.
8. resizeBy () usage: [<window Object>.] resizeBy (deltaWidth, deltaHeight); adjust the window size, increase the width of deltaWidth pixels, and increase the height of deltaHeight pixels. If the value is negative, the value is reduced.
9. alert () usage: alert (<string>); a dialog box containing only the "OK" button is displayed, showing the content of <string>, reading the entire document and running the Script will be paused until the user presses "OK ".
10. confirm () usage: confirm (<string>); a dialog box containing the "OK" and "cancel" buttons is displayed. The <string> content must be selected, reading the entire document and running the Script are paused. If you press "OK", true is returned. If you press "cancel", false is returned.
11. prompt () usage: prompt (<string> [, <initial value>]); a dialog box containing "OK" and "cancel" and a text box is displayed, showing <string> content, users are required to enter some data in the text box. Reading the entire document and running the Script are paused. If the user presses "OK", the existing content in the text box is returned. If the user presses "cancel", the return value is null. If <initial value> is specified, the default value is displayed in the text box.
4. Window objects have the following events:
1. window. onload; occurs when all documents are downloaded. After all the files are downloaded, not only HTML files, but also images, plug-ins, controls, applets, and other content are downloaded. This event is a window event, but when you specify an event handler in HTML, we write it in the <body> tag.
2. window. onunload; occurs when the user exits the document (or closes the window, or goes to another page. Like onload, it should be written in HTML and written into the <body> tag.
3. window. onresize; occurs when the window is adjusted.
4. window. onblur; occurs when the window loses focus.
5. window. onfocus; occurs when the window gets the focus.
6. window. onerror; occurs when an error occurs. Its event Handler is usually called an Error Handler to handle errors. As described above, to ignore all errors, use:
Function ignoreError (){
Return true;
}
Window. onerror = ignoreError;
As follows:
Object Attributes
Window // The window itself
Window. self // reference this window = window. self
Window. name // name the window
Window. defaultStatus // set the window status bar Information
Window. location // URL address. You can set this attribute to open a new page.
---------------------------------------------------------------------
Object Method
Window. alert ("text") // prompt message session box
Window. confirm ("text") // confirm the session box
Window. prompt ("text") // enter the session box on the keyboard.
Window. setIntervel ("action", time) // The operation is executed every specified time (milliseconds ).
Window. clearInterval () // The clearing time is configured to terminate the cycle.
Window. setTimeout (action, time) // The operation is executed every specified time (milliseconds ).
Window. open () // open a new window
Window. close () // close the window
---------------------------------------------------------------------
Member object
Window. event
Window.doc ument // For details, see the document object
Window. history
Window. screen
Window. navigator
Window. external
---------------------------------------------------------------------
---------------------------------------------------------------------
Window. history Object
Window. history. length // Number of browsed pages
History. back () // retreat
History. forward () // progress
History. go (I) // to the I position of the detailed history registration form, I> 0 progress, I <0 retreat
---------------------------------------------------------------------
Window. screen Object
Window. screen. width // screen width
Window. screen. height // screen height
Window. screen. colorDepth // screen color depth
Window. screen. availWidth // available width
Window. screen. availHeight // available height (excluding the height of the taskbar)
---------------------------------------------------------------------
Window. external Object
Window. external. AddFavorite ("Address", "title") // Add the website to the folder
---------------------------------------------------------------------
Window. navigator object
Window. navigator. appCodeName // browser code name
Window. navigator. appName // browser step name
Window. navigator. appMinorVersion // browser patch version
Window. navigator. cpuClass // CPU type x86
Window. navigator. platform // operating system type win32
Window. navigator. plugins
Window. navigator. opsProfile
Window. navigator. userProfile
Window. navigator. systemLanguage // zh-cn Simplified Chinese
Window. navigator. userLanguage // user language, same as above
Window. navigator. appVersion // browser version (including System Version)
Window. navigator. userAgent
Window. navigator. onLine // whether the user is onLine
Window. navigator. cookieEnabled // does the browser support cookies?
Window. navigator. mimeTypes
[Document Object]
This object is an attribute of the window and frames objects. It is a document displayed in a window or frame.
Attribute
1. alinkColor activity link color (ALINK)
2. anchor is an HTMI anchor. It is created with the <a name => MARK (this attribute is also an object)
3. anchors array lists the array of document anchors (<a name =>) (This attribute is also an object)
4. bgColor (BGCOLOR)
5. cookie is stored in a piece of information in the cookie.txt file. It is an attribute of the Document Object.
6. TEXT color of the fgColor document (TEXT features in the <BODY> MARK)
7. form (<FORM>) (This attribute is also an object)
8. forms anay lists an array of form objects in the order they appear in the document (this attribute is also an object)
9. lastModified document last modification date
10. The LINK color of the linkColor document, that is, the LINK feature in the <BODY> MARK (LINK to the document not observed by the user)
11. A <a href => mark in the link document (this attribute is also an object)
12. An array of link objects in the links array document, arranged in the order they appear in the document (the attribute itself is also an object)
13. location: the URL of the currently displayed document. You cannot change document. location (because this is the location of the currently displayed document ). However, you can change window. location (Replace the current document with other documents). window. location is an object, and document. location is not an object.
14. The URL of the document whose referrer contains the link. You can click this link to reach the current document.
15. title of the document (TITLE>)
16. vlinkColor points to the link text color of the document you have observed, that is, the VLINK feature marked by <BODY>.
Method
1. clear the content of the specified document
2. close to close the Document Stream
3. open the Document Stream
4. write the text into the document
5. writeln writes text to the document and ends with a linefeed.