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 Handleeve NT Releaseevent routeevent Scroll
1. Open method
Syntax format: window.open (URL, window name, window style)
Function: Opens a new window and loads the 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;
The Open method can also specify the name of the window (the second argument) when it opens a new browser window;
The Open method can also specify the style of the window (the third argument) when you open a new browser window, with the following options for the window style, which can be multiple selections and, if multiple selections, separated by commas:
Toolbar: Specifies whether the window has a standard toolbar. When the value of this option is 1 or Yes, a standard toolbar is represented, and when the value of the option is 0 or no, there is no standard toolbar;
Location: Specifies whether the window has an address toolbar, and the value and meaning of the option are the same as toolbar;
Directories: Specifies whether the window has a link toolbar, and the value and meaning of the option is the same as toolbar;
Status: Specifies whether the window has a status bar, and the value and meaning of the option are the same as toolbar;
MenuBar: Specifies whether the window has a menu, the value of the option and the meaning is the same as toolbar;
ScrollBar: Specifies whether scroll bars are available when the current window document is larger than the window, and the value and meaning of the option are 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: in pixels, the window is specified to be innerwidth replaced;
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 outer height of the window in pixels;
Left: Specifies, in pixels, the position of the window from the left-hand side of the screen;
Top: Specifies, in pixels, the position of the window from the tip of the screen;
Alwayslowered: Specifies that the window is hidden behind all windows, and that the value and meaning of the option are the same as toolbar;
Alwaysraised: Specifies that the window floats above all windows, and that the value and meaning of the option are the same as toolbar;
Dependent: Specifies that the open window is a child of the current window and closes with the parent window closed, with the value and meaning of the option the same as the toolbar;
Hotkeys: Set a safe exit hotkey in a new window without a menu bar, and the value and meaning of the option are the same as toolbar;
Innerheight: Set the pixel height of the Chinese file in the window;
Innerwidth: Set the pixel width of the Chinese file 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 boundary 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.
Tip: This method is often used to open another window automatically when you open a Web page.
2. Close method
Syntax format: window.close ()
Function: The Close method closes the browser window automatically.
3. Alert method
Syntax format: window.alert (hint string)
Function: A warning box pops up, and a hint string text appears in the Warning box.
4. Confirm method
Syntax format: window.confirm (hint string)
Function: Displays a confirmation box, displays the prompt string in the confirmation box, returns True when the user clicks the OK button, and returns False when clicking 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 the string entered by the user 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: Timed setting, automatically executes the code character expression after the specified number of milliseconds.
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 (the second parameter), repeatedly executes the contents of the "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, vertical displacement amount)
Function: Moves the specified window according to the given pixel parameters. The first argument is the pixel that the window moves horizontally, and the second is the pixel that the window moves vertically.
11.moveTo method
Syntax format: Window.moveto (x,y)
Function: Moves the window to the specified coordinates (X,Y).
Resizeby method
Syntax format: Window.resizeby (horizontal, vertical)
Function: Changes the current window to a specified size (x,y) and shrinks when the value of x and Y is greater than 0, and less than 0.
Resizeto method
Syntax format: window.resizeto (horizontal width, vertical width)
Function: Change the current window to (x,y) size, x, y is width and height respectively.
Scrollby method
Syntax format: Window.scrollby (horizontal displacement, vertical displacement amount)
Function: Scrolls the contents of a window by a given amount of displacement. When the argument is positive, it scrolls forward, otherwise it scrolls backwards.
Scrollto method
Syntax format: Window.scrollto (x,y)
Function: Scrolls the contents of a window to a specified location.
16.find method
Syntax format: window.find ()
Function: When this method is triggered, a Find dialog window pops up and allows the user to look up a string in the page that triggers the Find method.
Note: This property is not supported in both IE5.5 and Netscape6.0.
Back method
Syntax format: window.back ()
Function: Simulate the user clicks the "Back" button on the browser and turn the page to the previous page of the browser.
Description: This action can only be performed 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: Simulate the user clicks on the "Forward" button on the browser, the page will be transferred to the next page of the browser.
Description: This action can only be performed if the current page exists on the next page.
Note: IE5.5 does not support this method, Netscape6.0 support.
Home method
Syntax format: window.home ()
Function: Simulate the user clicks on the browser "Home" button, the page will be transferred to the specified page.
Note: IE5.5 does not support this method, Netscape6.0 support.
Stop method
Syntax format: window.stop ()
Function: Simulate the user clicks the "Stop" button on the browser, terminate the download operation of the browser.
Note: IE5.5 does not support this method, Netscape6.0 support.
Print method
Syntax format: window.print ()
Function: Simulate the user clicks the "Print" button on the browser, inform 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. You must be careful when pooling with the focus method, because it can cause the focal point to move in and out.
Focus Method
Syntax format: Window.focus ()
Function: Gets the focus in the window. Be careful when sharing with the Blur method because it can cause focus to move in and out
Captureevent method
Syntax format: window.captureevent (Event)
Window.captureevent (Event 1| Event 2|...| Event N)
Function: Captures all events for the specified parameter. Because of the ability to capture events that are handled by local programs themselves, programmers can define functions to handle events at will. If more than one event needs to be captured, the pipe character "|" is used between the events. Separated. The types of events that can be captured are as follows:
Event.abort event.blur event.change event.click event.dblclick event.dragdrop event.error event.focus Event.keydown Event.keypress event.keyup event.load event.mousedown event.mousuemove event.mouseout event.mouseover event.mouseup Event.move event.reset event.resize event.select event.submit event.unload
Enableexternalcapture incident
Syntax format: window.enableexternalcapture (Event)
Function: The Enableexternalcapture method is used to catch external events passed in by parameters.
Disableexternalcapture incident
Syntax format: window.disableexternalcapture ()
Function: Cancels the setting of the Enableexternalcapture method and terminates the capture of external events.
Handleevent incident
Syntax format: window.handleevent (Event)
function: Triggers the event handler for the specified event.
Releaseevent incident
Syntax format: window.releaseevent (Event)
Window.releaseevent (Event 1| Event 2|...| Event N)
Function: Releases the captured events passed in by the parameter, which are set by the Window.captureevent method and can be released in the same event as Captureevent.
Routeevent incident
Syntax format: window.releaseevent (Event)
Function: All events of the captured type are forwarded to the standard event handling method for processing, and the Captureevent events are the same.
Scroll Event
Syntax format: window.scroll (x-coordinate, y-coordinate)
Function: Moves the window to the specified coordinate position.
Properties of Window objects
The Window object has the following properties:
Status StatusBar statusbar.visible defaultstatus location Locationbar locationbar.visible self name closed frames. Length length document history innerheight Innerwidth menubar menubar.visible opener Outerheight Outerwidth pagexoffset PA Geyoffset parent Personalbar personalbar.visible ScrollBar scrollbar.visible Toolbar Top
1. Status Property
Syntax format: window.status= string
Function: Sets or gives the current display information for the status bar in the browser window.
Tip: You can use this property to set the browser window status bar information.
2. StatusBar Properties
Syntax format: Window.statusbar. Properties
Function: The StatusBar property itself is also an object that accesses its own visible property to determine whether the status bar is visible.
Note: The ie5.5 browser does not support this property.
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.
Note: The ie5.5 browser does not support this property.
4. Defaultstatus Properties
Syntax format: window.defaultstatus[= string]
Function: 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 for 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 child 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: This property is not supported by ie5.5.
7. Locationbar.visible Properties
Syntax format: window.locationbar.visible
Function: Returns whether the position bar is visible, returns true if visible, and returns false.
Note: This property is not supported by ie5.5.
8. Self attribute
Syntax format: window.self. method
Window.self. Properties
Function: This property contains the flag of the current window, which enables you to make proper calls to functions or properties within the current window without confusion if multiple windows are open.
9. Name property
Syntax format: window.name= name
Function: Returns the name of the window given when a 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 when it comes to the javascript1.1 version, use this property to assign a name to 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 whether an instance of the specified window is turned off, return true if it is closed, or return flase.
Frames Properties
Syntax format: window.frames["frame name"
window.frames[value]
Function: The Frames property is an array that stores each instance of a child window (frame) created by the element in the document, where the subscript can be either a secondary ordinal number or a name specified with the frame element's names property.
Frames.length Properties
Syntax format: window.frames.length
Function: The Frames.length property is used to give the number of instances of a document's neutron window (frame).
Length Property
Syntax format: window.length
Function: The Length property returns the number of child windows within a window that is the same as the value of the Window.frame.length property.
Document properties
Syntax format: window.document. Event Window.document. Method Window.document. Attribute
Features: The child object document of the Window object is the core object of JavaScript, creating an instance when the BODY element is encountered in the script.
History properties
Syntax format: window.history[value] window.history. Method () Window.history. property
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 toolbars and the height of the page decorations that make up the window.
Note: This property is not supported by ie5.5.
Innerwidth Property
Syntax format: window.innerheight= value
Function: Returns or specifies the pixel width of the document in the browser window, which does not include any toolbars and the page decoration widths that make up the window.
Note: This property is not supported by ie5.5.
MenuBar Properties
Syntax format: Window.menubar. Properties
Function: The MenuBar property can also be viewed as a child object that 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: This property is not supported by ie5.5.
Menubar.visible Properties
Syntax format: window.menubar.visible
Function: The Menubar.visible property is used to return whether the menu bar is visible and returns true if it is visible, false instead.
Note: This property is not supported by ie5.5.
Opener Properties
Syntax format: Window.opener window.opener. Method 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 enables you to use methods and properties in the parent window object.
Outerheight Property
Syntax format: window.outerheight
Function: The Outerheight property is used to access the pixel height of the browser window, which includes the height of the toolbar and the trim edge.
Note: This property is not supported by ie5.5.
Outerwidth Properties
Syntax format: window.outerwidth
Function: The Outerwidth property is used to access the pixel width of the browser window, which includes the width of the toolbar and the trim edge.
Note: This property is not supported by ie5.5.
Pagexoffset Properties
Syntax format: window.pagexoffset= value
Function: Specifies the current horizontal pixel position in the window in the upper-left corner of the browser window's Chinese file. You can use this property to determine whether you need to move a window before using MoveTo to move. Because this property returns the current position of the visible document relative to the entire page.
Note: This property is not supported by ie5.5.
pageYOffset Properties
Syntax format: window.pageyoffset= value
Function: Specifies the current vertical pixel position in the window in the upper-left corner of the browser window's Chinese file. You can use this property to determine whether you need to move a window before using MoveTo to move. Because this property returns the current position of the visible document relative to the entire page.
Note: This property is not supported by ie5.5.
Parent Property
Syntax format: window.parent.frames[value] Window.parent.framesname
Features: Accesses the parent window of each child window (multiple frames).
Personalbar Property
Syntax format: Window.personalbar. Properties
Function: The Personalbar property itself is also an object that accesses its own visible property to determine whether the personal bar is visible.
Note: This property is not supported by ie5.5.
Personalbar.visible Property
Syntax format: window.personalbar.visible
Function: Determines whether the personal bar is visible, returns True if it is visible, and returns false.
Note: This property is not supported by ie5.5.
ScrollBars Properties
Syntax format: Window.scrollbars. Properties
Function: The ScrollBars property itself is also an object that accesses its own visible property to determine whether the scroll bar is visible
Note: This property is not supported by ie5.5.
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.
Note: This property is not supported by ie5.5.
Toolbar properties
Syntax format: Window.toolbar. Properties
Function: The toolbar property itself is also an object that accesses its own visible property to determine whether the toolbar is visible.
Note: This property is not supported by ie5.5.
Toolbar.visible Property
Syntax format: window.toolbar.visible
Function: The Toolbar.visible property checks whether the toolbar is visible, returns True if it is visible, and returns false.
Note: This property is not supported by ie5.5.
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 mounted browser's child windows (multiple frames).