Window Object
Window objects are supported by all browsers. It represents the browser window.
All JavaScript global objects, functions, and variables automatically become members of the Window object.
A global variable is a property of a Window object.
A global function is a method of a Window object.
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.
The window style has the following options, which can be selected more than one option, separated by commas if multiple selections:
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, and when the user clicks the OK button
The method returns true and False when you click Cancel.
5. Prompt method
Syntax format:
WINDOW.PROMPT (hint string, default text)
Features: Displays an input box, displays the prompt string in the input box, and displays the default text in the Input text box
This, and waits for user input, when the user clicks the "OK" button, returns the user input string, when
Returns a null value when you click the Cancel button.
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)
Function: Moves the specified window according to the given pixel parameters. The first argument is the pixel at which the window moves horizontally,
Two parameters are pixels 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 the specified size (x,y) and expands when the value of x and Y is greater than 0, less than 0 o'clock
To shrink.
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)
Function: Scrolls the contents of a window by a given amount of displacement. When the argument is positive, it scrolls forward, otherwise the inverse
To scroll.
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 touch
Find a string in the page where you send the search 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, informs 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. Be careful when sharing with the focus method, because it can cause focused
Constantly 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 may cause the focus to not
Break move in and move 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 you can capture which events are handled by the local program itself
, so programmers can arbitrarily define functions to handle events. If there are multiple events that need to be captured, the events
With the pipe character "|" 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 through the parameter, which are
The Window.captureevent method is set, and the event that can be released is the same as captureevent.
Routeevent incident
Syntax format:
Window.releaseevent (Event)
Function: Transfer all events of a captured type to a standard event-handling method for processing, which can be forwarded
Pieces are the same as captureevent.
Scroll Event
Syntax format:
Window.Scroll (x coordinates, y coordinates)
Function: Moves the window to the specified coordinate position.
The Window object has the following properties:
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
The fixed 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: 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 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 can be used to ensure that multiple windows are opened
, the function or property within the current window is called correctly without confusion.
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 the
javascript1.1 version, you can use this property to give an attribute that is not created with the window.open () method.
window to specify a name.
Closed properties
Syntax format:
Window.closed
Function: The closed property is used to return whether an instance of the specified window is closed, and returns True if it is closed
, and return to Flase instead.
Frames Properties
Syntax format:
window.frames["frame name"]
window.frames[value]
Function: The Frames property is an array that stores every child window created by the element in the document (box
instance, where the subscript can be a secondary ordinal number or a name specified with the Name property of the FRAME element
Called to get and use.
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 associated with the
The value of the Window.frame.length property is the same.
Document properties
Syntax format:
Window.document. Events
Window.document. Method
Window.document. Properties
Features: The child object document of the Window object is the core object of JavaScript, encountered in the script
Creates an instance when the BODY element is created.
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 a
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 page-decoration height that makes 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 width that makes 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, 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: 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 if the visible returns true, the inverse
returns FALSE.
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 toolbar and
The height of 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 toolbar and the loaded
The width of 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. In using
You can use this property to determine whether you need to move a window before moveto move. Because the property returns the
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. In using
You can use this property to determine whether you need to move a window before moveto move. Because the property returns the
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 confirm
Make sure the personal column 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 confirm
Whether the fixed scroll bar is visible.
Note: This property is not supported by IE5.5.
Scrollbars.visible Properties
Syntax format:
Window.scrollbars.visible
Function: Scrollbars.visible is used to determine whether the scroll bar is visible and returns true if it is visible, anti
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 is used to check whether the toolbar is visible and returns true if it is visible.
return false instead.
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).
The above mentioned is the entire content of this article, I hope you can enjoy.