Summary of methods and properties of the Window object "summarizing--window objects"

Source: Internet
Author: User

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 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, the Standard toolbar is represented, and when the value of this 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 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.

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 continuously in and 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, 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.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 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.

Scroll events

Syntax format: window.scroll (x-coordinate, y-coordinate)

Function: Moves the window to the specified coordinate position.

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 PA Geyoffset 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

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: 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.

Expand:

1, sets or gets the file name or path specified by the object.

Alert (Window.location.pathname)

2, sets or gets the entire URL as a string.

alert (WINDOW.LOCATION.HREF);

3, set or get the port number associated with the URL.

Alert (Window.location.port)

4, set or get the protocol portion of the URL.

Alert (Window.location.protocol)

5, set or get the segment after the pound sign "#" in the href attribute.

Alert (Window.location.hash)

6. Set or get the hostname and port numbers for the location or URL.

Alert (Window.location.host)

7, set or get the portion of the HREF attribute that follows the question mark.

Alert (Window.location.search)

8, get the value of the variable (intercept the part after the equals sign)

var url = window.location.search;

alert (url.length);

Alert (url.lastindexof (' = '));

var loc = url.substring (url.lastindexof (' = ') +1, url.length);

9, the domain name used to get the current page

var domain = Document.domain;

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. Event Window.document. Method 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. 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 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.

Summary of methods and properties of the Window object "summarizing--window objects"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.