The Window object is one of the top-level objects of the client-side JavaScript, and whenever you open a browser window, regardless of whether there are open pages in that window, an instance of the Window object is created automatically when you encounter a body, frameset, or FRAME element. Also, an instance of the object can be created by the window.open () method. Because the window object is a common ancestor of most other objects, you can omit a reference to the Window object when invoking the methods and properties of the Window object. For example: Window.document.write () can be simply written as: document.write (). You can omit the window's instance name when you PIDM minimises any methods and properties of the Window object in the window. For example, when you set the Status property for the current Mywin window, you can use status instead of Mywin.status. However, you must use the instance name when you call the Location property, the Close () method, or the open () method in event handling.
the Window object has the following methods:Open
Close
Alert
Confirm
Prompt
SetTimeout
Cleartimeout
SetInterval
Clearinterval
Moveby
MoveTo
Resizeby
Resizeto
Scrollby
ScrollTo
Find
Back
Forward
Home
Stop
Print
Blur
Focus
Captureevent
Enableexternalcapture
Disableexternalcapture
Handleevent
Releaseevent
Routeevent
Scroll
1. Open Method
Syntax format: window.open (URL, window name, window style)
Function: Opens a new window and loads the Web page with the specified URL address in the window. Description: The Open method opens a new browser window and loads a specified URL address in a new window;
Open method when opening a new browser window, you can also specify the name of the window (the second parameter);
Open method when opening a new browser window, you can also specify the style of the window (the third parameter), the window style has the following options, these options can be multi-select, if multiple selection, the options are separated by commas:
Toolbar: Specifies whether the window has a standard toolbar. When the value of this option is 1 or yes, there is a standard toolbar that indicates that there is no standard toolbar when the value of this option is 0 or no;
Location: Specifies whether the window has an address toolbar, and the value and meaning of the option is the same as toolbar;
Directories: Specifies whether the window has a link toolbar, the value and meaning of the option is the same as toolbar;
Status: Specifies whether the window has a status bar, the value and meaning of the option is the same as toolbar;
MenuBar: Specifies whether the window has a menu, the value and meaning of the option is the same as toolbar;
ScrollBar: Specifies whether there are scroll bars when the current window document is larger than the window, and the value and meaning of the option is the same as toolbar;
Resizable: Specifies whether the window can be resized, and the value and meaning of the option is the same as toolbar;
Width: Specifies the width of the window in pixels, which has been replaced by innerwidth;
Height: Specifies the height of the window in pixels, which has been replaced by Innerheight;
Outerwidth: Specifies the external width of the window in pixels;
Outerheight: Specifies the external height of the window in pixels;
Left: Specifies, in pixels, the position of the window from the side of the screen;
Top: Specifies the position of the window from the top of the screen in pixels;
Alwayslowered: The specified window is hidden behind all windows, and the value and meaning of the option is the same as toolbar;
Alwaysraised: Specifies that the window floats above all windows, and the value and meaning of the option is the same as toolbar;
Dependent: Specifies that the open window is a subwindow of the current window, and that the value and meaning of the option are the same as the toolbar when the parent window is closed;
Hotkeys: Set the safe exit hotkey in a new window without the menu bar, the value and meaning of the option is the same as toolbar;
Innerheight: Sets the pixel height of the document in the window;
Innerwidth: Sets the pixel width of the document in the window;
ScreenX: Sets the pixel length of the window from the left edge of the screen;
ScreenY: Sets the pixel length of the window from the upper edge of the screen;
TitleBar: Indicates whether the title bar is visible in a new window, and the value and meaning of the option is the same as toolbar;
Z-look: Indicates that when a window is activated, it cannot float on top of other windows, and the value and meaning of the option are the same as toolbar. The Open method returns a reference to the window.Tips:This method is often used to automatically open another window when a Web page is opened.2. The Close method
Syntax format: window.close ()
Function: The Close method is used to automatically close the browser window.3. Alert Method
Syntax format: window.alert (hint string)
function: pops up a warning box to display the prompt string text in the warning box.4. Confirm method
Syntax format: window.confirm (hint string)
Function: Displays a confirmation box, displays a prompt string in the confirmation box, returns True when the user clicks the OK button, and returns False when you click Cancel.5. Prompt method
Syntax format: window.prompt (hint string, default text)
Function: Displays an input box, displays the prompt string in the input box, displays the default text in the input text box, waits for user input, returns a string that the user entered when the user clicks the OK button, and returns a null value when the Cancel button is clicked.6. SetTimeout method
Syntax format: window.settimeout (code character expression, number of milliseconds)
Function: Timing setting, automatically executes the code character expression when the specified number of milliseconds is reached.7. Cleartimeout method
Syntax format: window.cleartimeout (timer)
Function: Cancels the previous timer setting, where the parameter is the return value when set with SetTimeout.8. SetInterval Method
Syntax format: window.setinterval (code character expression, number of milliseconds)
Function: After setting a time interval (second parameter), repeat the contents of "Code character expression"9. Clearinterval Method
Syntax format: window.clearinterval (Time spacer)
Function: Cancels the timing of the setinterval setting. The parameter is the return value of the SetInterval method.Moveby Method
Syntax format: window.moveby (horizontal displacement amount, vertical displacement amount)
Function: Moves the specified window according to the given pixel parameters. The first parameter is the pixels that the window moves horizontally, and the second parameter is the pixels that the window moves vertically.11.moveTo method
Syntax format: Window.moveto (x, y)
Function: Moves the window to the specified specified coordinates (x, y).Resizeby Method
Syntax format: Window.resizeby (horizontal, vertical)
Function: Changes the current window to the specified size (x, y) and expands when the value of x, Y is greater than 0, and shrinks when it is less than 0.Resizeto Method
Syntax format: window.resizeto (horizontal width, vertical width)
Function: Changes the current window to an (x, y) size, and x, Y are width and height, respectively.Scrollby Method
Syntax format: Window.scrollby (horizontal displacement amount, vertical displacement amount)
Function: Scrolls the contents of a window by a given amount of displacement. When the parameter is positive, it scrolls forward, otherwise it scrolls backwards.Scrollto Method
Syntax format: Window.scrollto (x, y)
Function: Scrolls the contents of the window to the specified position.16.find Method
Syntax format: window.find ()
Function: When this method is triggered, a "Find" dialog window pops up and allows the user to find a string in the page that triggers the Find method.Note:This property is not supported in IE5.5 and Netscape6.0.. Back Method
Syntax format: window.back ()
Function: Simulates the user to click on the "Back" button on the browser to move the page to the previous page of the browser. Description: This action can be performed only if the current page has a previous page.Note:IE5.5 does not support this method, Netscape6.0 support.Forward Method
Syntax format: Window.forward ()
Function: Simulates the user to click on the "Forward" button on the browser to move the page to the next page of the browser. Description: This action is available only if the next page exists on the current page.Note:IE5.5 does not support this method, Netscape6.0 support.. Home Method
Syntax format: window.home ()
Function: Simulates the user to click on the "Home" button on the browser to move the page to the specified page.Note:IE5.5 does not support this method, Netscape6.0 support.. Stop Method
Syntax format: window.stop ()
Function: Simulates the user to click the "Stop" button on the browser to terminate the browser's download operation.Note:IE5.5 does not support this method, Netscape6.0 support.. Print method
Syntax format: window.print ()
Function: Simulates the user to click on the "Print" button on the browser to notify the browser to open the Print dialog box to print the current page.Blur Method
Syntax format: Window.blur ()
Function: Removes the focus from the window. Care must be taken when combined with the focus method, as it may cause the focus to move in and out continuously.. Focus Method
Syntax format: Window.focus ()
Function: Gets the focus in the window. Care must be taken when combined with the Blur method, as it may cause the focus to move in and out continuously.Captureevent Method
Syntax format: window.captureevent (Event)
Window.captureevent (Event 1| Event 2|...| Event N)
Function: Captures all events of the specified parameter. Because of the ability to capture events that are handled by the local program itself, programmers can arbitrarily define functions to handle events. If there are multiple events that need to be snapped, the pipe break between the events "|" Separated. The types of events that can be captured are as follows: Event.ABORTEvent.BLUREvent.CHANGEEvent.CLICKEvent.DBLCLICKEvent.DRAGDROPEvent.ERROREvent.FOCUSEvent.KEYDOWNEve Nt. KEYPRESSEvent.KEYUPEvent.LOADEvent.MOUSEDOWNEvent.MOUSUEMOVEEvent.MOUSEOUTEvent.MOUSEOVEREvent.MOUSEUPEvent.MOVEEvent.RES ETEvent.RESIZEEvent.SELECTEvent.SUBMITEvent.UNLOADEnableexternalcapture Event
Syntax format: window.enableexternalcapture (Event)
Function: The Enableexternalcapture method is used to capture external events that pass through parameters.disableexternalcapture Events
Syntax format: window.disableexternalcapture ()
Function: Cancels the setting of the Enableexternalcapture method, terminating the capture of the external event.handleevent Events
Syntax format: window.handleevent (Event)
Function: Event handler that triggers the specified event.releaseevent Events
Syntax format: window.releaseevent (Event)
Window.releaseevent (Event 1| Event 2|...| Event N)
Function: Releases the captured events passed through the parameters, which are set by the Window.captureevent method and can be disposed of in the same event as Captureevent.routeevent Events
Syntax format: window.releaseevent (Event)
Function: Transfers all events of the captured type to the standard event processing method, which can be transmitted in the same event as Captureevent.The Scroll event
Syntax format: window.scroll (x-coordinate, y-coordinate)
Function: Moves the window to the specified coordinate position.
The Window object has the following properties:Statusstatusbarstatusbar.visibledefaultstatuslocationlocationbarlocationbar.visibleselfnameclosedframesframes.lengthlengt Hdocumenthistoryinnerheightinnerwidthmenubarmenubar.visibleopenerouterheightouterwidthpagexoffsetpageyoffsetparentpersona Lbarpersonalbar.visiblescrollbarscrollbar.visibletoolbartoolbar.visibletop1. Status Property
Syntax format: window.status= string
Function: Sets or gives the current display information for the status bar in the browser window.Tips:You can use this property to set the browser window status bar information. 2. StatusBar Properties
Syntax format: Window.statusbar. Properties
Features: The StatusBar property itself is also an object that accesses its own visible property to determine whether the status bar is visible. Note: This property is not supported by the IE5.5 browser.3. Statusbar.visible Properties
Syntax format: window.statusbar.visible
Function: Checks whether the status bar is visible, returns True if it is visible, and returns false instead.Note:This property is not supported by the IE5.5 browser. 4. Defaultstatus Properties
Syntax format: window.defaultstatus[= string]
Function: The Defaultstatus property value is the default display information for the status bar in the browser window.5.location Properties
Syntax format: Window.location=url
Function: gives the URL information of the current window or specifies the URL of the open window.6. Locationbar Properties
Syntax format: Window.locationbar. Properties
Function: The Locationbar property can also be viewed as a sub-object, which is used to obtain its own visible property to determine whether the position bar is visible. So far, this property has only one child property: visible.Note:IE5.5 does not support this property. 7. Locationbar.visible Properties
Syntax format: window.locationbar.visible
Function: Returns whether the position bar is visible, returns True if it is visible, and returns false instead.Note:IE5.5 does not support this property. 8. Self property
Syntax format: window.self. method
Window.self. Properties
Function: This property contains the flags of the current window, which ensures that functions or properties within the current window are correctly invoked without confusion when multiple windows are opened.9. Name Property
Syntax format: window.name= name
Function: Returns the name of the window that is given when the new window is created by the window.open () method. In the javascript1.0 version, this property can only be used to read the window name, and to the javascript1.1 version, you can use this property to specify a name for a window that is not created with the window.open () method.Closed Properties
Syntax format: window.closed
Function: The closed property is used to return the instance of the specified window if it is closed, returns True if closed, and vice versa. Flase.One . Frames Properties
Syntax format: window.frames["frame name"]
window.frames[value]
Features: The Frames property is an array that stores every instance of a child window (frame) created by an element in a document, where the subscript can be a secondary ordinal or can be obtained and used using a name specified by the frame element's Name property.Frames.length Properties
Syntax format: window.frames.length
Function: The Frames.length property is used to give the number of instances of a child window (frame) in a document.Length Property
Syntax format: window.length
Function: The Length property returns the number of child windows within a window, which is the same as the value of the Window.frame.length property.. Document Property
Syntax format: window.document. Events
Window.document. Methods
Window.document. Properties
Function: The child object of the Window object document is the core object of JavaScript, and an instance is created when the BODY element is encountered in the script.. History Properties
Syntax format: window.history[value]
Window.history. Method ()
Window.history. Properties
The child object of the Window object history is one of the core objects of JavaScript, which contains an array of the names and URLs of the pages that have been visited.Innerheight Properties
Syntax format: window.innerheight= value
Function: Returns or specifies the pixel height of the document in the browser window, which does not include any toolbar or page decoration height that makes up the window.Note:IE5.5 does not support this property.Innerwidth Properties
Syntax format: window.innerheight= value
Function: Returns or specifies the pixel width of the document in the browser window, which does not include any toolbar or page decoration width that makes up the window.Note:IE5.5 does not support this property.MenuBar Properties
Syntax format: Window.menubar. Properties
Function: The MenuBar property can also be considered a sub-object, which is used to obtain its own visible property to determine whether the menu bar is visible. So far, this property has only one child property: visible.Note:IE5.5 does not support this property.. Menubar.visible Properties
Syntax format: window.menubar.visible
Function: The Menubar.visible property is used to return whether the menu bar is visible or false if visible returns True.Note:IE5.5 does not support this property.Opener Properties
Syntax format: Window.opener
Window.opener. Methods
Window.opener. Properties
Function: The opener property is associated with the parent window that opens the window, and when you access the Operer property in the child window, the parent window is returned. This property allows you to use methods and properties in the parent window object.. Outerheight Properties
Syntax format: window.outerheight
Features: The Outerheight property is used to access the pixel height of the browser window, which includes the height of the toolbar and trim edges.Note:IE5.5 does not support this property.Outerwidth Properties
Syntax format: window.outerwidth
Features: The Outerwidth property is used to access the pixel width of the browser window, which includes the width of the toolbar and trim edges.Note:IE5.5 does not support this property.. Pagexoffset Properties
Syntax format: window.pagexoffset= value
Function: Specifies the current horizontal pixel position of the upper-left corner of the file in the window in the browser window. You can use this property to determine whether you need to move a window before you move with MoveTo. Because this property returns the current position of the visible document relative to the entire page.Note:IE5.5 does not support this property.pageYOffset Properties
Syntax format: window.pageyoffset= value
Function: Specifies the current vertical pixel position of the upper-left corner of the file in the window in the browser window. You can use this property to determine whether you need to move a window before you move with MoveTo. Because this property returns the current position of the visible document relative to the entire page.Note:IE5.5 does not support this property.. Parent Property
Syntax format: window.parent.frames[value]
Window.parent.framesName
Function: Access the parent window where each child window (multi-frame) resides.Personalbar Properties
Syntax format: Window.personalbar. Properties
Features: The Personalbar property itself is also an object that accesses its own visible property to determine whether the personal column is visible.Note:IE5.5 does not support this property.personalbar.visible Properties
Syntax format: window.personalbar.visible
Function: Determines whether the personal bar is visible, returns True if it is visible, and returns false instead.Note:IE5.5 does not support this property.ScrollBars Properties
Syntax format: Window.scrollbars. Properties
Features: The ScrollBars property itself is also an object that accesses its own visible property to determine whether the scroll bar is visible.Note:IE5.5 does not support this property.. Scrollbars.visible Properties
Syntax format: window.scrollbars.visible
Function: Scrollbars.visible Determines whether the scroll bar is visible, returns True if it is visible, and returns false instead.Note:IE5.5 does not support this property.. Toolbar Properties
Syntax format: Window.toolbar. Properties
Features: The toolbar property itself is also an object that accesses its own visible property to determine whether the toolbar is visible.Note:IE5.5 does not support this property.toolbar.visible Properties
Syntax format: window.toolbar.visible
Function: The Toolbar.visible property is used to check if the toolbar is visible, returns True if it is visible, and returns false instead.Note:IE5.5 does not support this property.Top Properties
Syntax format: window.top.frames[value]
Window.top.frameName
Window.top. Method ()
Window.top. Properties
Function: The top property of the Window object is used to contain information about the topmost window of all the child windows (multiple frames) that are loaded into the browser.
Window object Details (reprint)