S-window object's methods and property data
HXPD posted on 2007-05-08 21:58:18 The Windows object's open, close, alert, confirm, prompt, SetTimeout, cleartimeout, SetInterval, Use of Clearinterval, Moveby, Resizeby, Scrollby methods
Mastering the use of the MoveTo, Resizeto, ScrollTo, and Print methods of the Window object
Proficiency in the use of the Window object's status, location, name, self, and opener property is one of the top-level objects of the client-side JavaScript, as long as the browser window is open, regardless of whether there are open pages in that window. When a body, frameset, or frame element is encountered, an instance of the Window object is created automatically. 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.
Methods for 6-2-1 Window objects
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.
Tip: This method is often used to automatically open another window when a Web page is opened.
Example 6-2-1: Develop a small program that automatically opens another window when the current window is opened, to
The window does not have a standard toolbar, address bar, link toolbar, menu bar, but there is a status bar, Windows hit
The address of the Web page opened is: http://www.dlrtvu.edu.cn.
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)
Features: Displays a confirmation box that displays a prompt string in the confirmation box when the user clicks the OK button
When this method returns True, False is returned when you click Cancel.
5. Prompt method
Syntax format:
WINDOW.PROMPT (hint string, default text)
Function: Display an input box, display the prompt string in the input box, display the default text in the Input text box
When the user clicks the "OK" button, the user input string is returned when the
When you click the Cancel button, a null value is returned.
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)
Function: Moves the specified window according to the given pixel parameters. The first parameter is the pixel that the window moves horizontally, and the second
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 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, less than 0 o'clock
To zoom out.
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)
Function: Scrolls the contents of a window by a given amount of displacement. When the parameter is positive, it scrolls forward, otherwise the inverse
To scroll.
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
Finds a string in the page that sends 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: Simulate the user click the "Print" button on the browser, notify the browser to open the Print dialog box printing
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 focus
Keep moving in and out.
. 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 focus not
The break-in-move-out.
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
, so programmers can arbitrarily define functions to handle events. If there are multiple events that need to be captured, each event
With the pipe symbol "|" 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 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
The Window.captureevent method is set, and the event that can be disposed is the same as captureevent.
Routeevent Events
Syntax format:
Window.releaseevent (Event)
Function: Transfer all events of the captured type to the standard event processing method, which can be transferred
Same as Captureevent.
The Scroll Event
Syntax format:
Window.Scroll (x-coordinate, y-coordinate)
Function: Moves the window to the specified coordinate position.
6-2-2 properties of the Window object
The Window object has the following properties:
Status
StatusBar
Statusbar.visible
Defaultstatus
Location
Locationbar
Locationbar.visible
Self
Name
Closed
Frames
Frames.length
Length
Document
History
Innerheight
Innerwidth
MenuBar
Menubar.visible
Opener
Outerheight
Outerwidth
Pagexoffset
pageYOffset
Parent
Personalbar
Personalbar.visible
ScrollBar
Scrollbar.visible
Toolbar
Toolbar.visible
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 ensure
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 considered a sub-object, which is used to obtain its own
The 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. Methods
Window.self. Properties
Features: This property contains the current window's flags, 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 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 the
javascript1.1 version, you can use this property for a window.open () method that is not created with the
window to specify a name.
Closed properties
Syntax format:
Window.closed
Function: The Closed property returns True if the instance of the specified window is closed, if it is closed
, instead of returning flase.
One. 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 an element in a document (box
Can be either a secondary ordinal 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 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 that is associated with the
The value of the Window.frame.length property is the same.
. 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 is encountered in the script
The BODY element when an instance 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, and this property 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, this height does not include any toolbars and
The 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 toolbars and
The 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
The 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, if visible returns True, the inverse
It returns false.
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 when the Operer property is accessed 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
Function: The Outerheight property is used to access the pixel height of the browser window, which includes toolbars and
The height of the decorative edge.
Note: IE5.5 does not support this property.
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 width of the trim.
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. In the use
This property can be used to determine whether a window needs to be moved before MoveTo moves. Because this property returns the
Shows the current position of the 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. In the use
This property can be used to determine whether a window needs to be moved before MoveTo moves. Because this property returns the
Shows the current position of the 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
Function: The Personalbar property itself is also an object that accesses its own visible property to
Determine if 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
Function: The ScrollBars property itself is also an object that accesses its own visible property to
The scroll bar is visible.
Note: IE5.5 does not support this property.
. scrollbars.visible Properties
Syntax format:
Window.scrollbars.visible
Function: Scrollbars.visible is used to determine if the scroll bar is visible and returns true if it is visible, anti-
It returns false.
Note: IE5.5 does not support this property.
. 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: 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 and returns true if it is visible.
Conversely, returns false.
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.
The complete analysis of JS window event