Jswindow object attributes and Methods

Source: Internet
Author: User

Jswindow object attributes and Methods

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 when your handleEvent releaseEvent routeEvent scroll

1. open Method

Syntax format: window. open (URL, window name, window style)

Function: open a new window and load the webpage with the specified URL address in the window.

Note:

The open method is used to open a new browser window and add a specified URL address to the new window;

When opening a new browser window, you can also specify the window name (the second parameter );

When opening a new browser window, you can also specify the window style (the third parameter). The window style has the following options, the options are separated by commas:

Toolbar: Specifies whether the window has a Standard toolbar. If the value of this option is 1 or yes, there is a Standard toolbar. If the value of this option is 0 or no, there is no standard toolbar;

Location: Specifies whether the window has an address toolbar. The options have the same value and meaning as toolbar;
Directories: Specifies whether the window has a linked toolbar. The options have the same value and meaning as the toolbar;
Status: Specifies whether the window has a status bar. The value and meaning of the option are the same as those of toolbar;
Menubar: Specifies whether a window has menus. The options have the same value and meaning as toolbar;
Scrollbar: Specifies whether a scroll bar exists when the document in the current window is greater than the window. The value and meaning of the option are the same as those in the toolbar;
Resizable: Specifies whether the window size can be changed. The value and meaning of the options are the same as those of toolbar;
Width: Specify the window width in pixels, which has been replaced by innerWidth;
Height: Specify the window height in pixels, which has been replaced by innerHeight;
OuterWidth: Specify the external width of the window in pixels;
OuterHeight: Specify the external height of the window in pixels;
Left: Specify the position of the window to the left of the screen in pixels;
Top: Specify the position of the window from the top of the screen in pixels;
AlwaysLowered: specifies that the window is hidden behind all windows. The value and meaning of the option are the same as that of the toolbar;
AlwaysRaised: specifies that the window floats above all windows. The value and meaning of the option are the same as those of the toolbar;
Dependent: Specify the window to be opened as a child window of the current window and close it as the parent window is closed. The value and meaning of the option are the same as that of the toolbar;
Hotkeys: Set the Security Exit hotkey in a new window without a menu bar. The value and meaning of the option are the same as those of toolbar;
InnerHeight: sets the pixel height of the document in the window;
InnerWidth: sets the pixel width of the document in the window;
ScreenX: Set the pixel length between the window and the left boundary of the screen;
ScreenY: Set the pixel length between the window and the upper boundary of the screen;
TitleBar: indicates whether the title bar is visible in a new window. The value and meaning of the option are the same as those of the toolbar;
Z-look: indicates that when a window is activated, it cannot float on other windows. The value and meaning of the option are the same as that of toolbar.
The open method returns a reference to the window.

Tip: This method is often used to automatically open another window when a webpage is opened.

2. 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 (prompt string)

Function: a warning box is displayed. The prompt string text is displayed in the warning box.

4. confirm Method

Syntax format: window. confirm (prompt string)

Function: A confirmation box is displayed. The prompt string is displayed in the confirmation box. If you click "OK", true is returned for this method and false is returned when you click "cancel.

5. prompt Method

Syntax format: window. prompt (prompt string, default text)

Function: displays an input box. A prompt string is displayed in the input box. The default text is displayed in the input text box. When you click OK, the string entered by the user is returned, if you click the cancel button, the return value is null.

6. setTimeout Method

Syntax format: window. setTimeout (Code character expression, in milliseconds)

Function: timed setting. When the specified number of milliseconds is reached, the Code character expression is automatically executed.

7. clearTimeout Method

Syntax format: window. clearTimeout (timer)

Function: cancels the previous scheduled setting. The parameter is the return value when setTimeout is used.

8. setInterval Method

Syntax format: window. setInterval (Code character expression, in milliseconds)

Function: after a time interval is set (the second parameter), the content of "code character expression" is repeatedly executed.

9. clearInterval Method

Syntax format: window. clearInterval (time interval)

Function: cancels the setInterval setting. The parameter is the return value of the setInterval method.

10. moveBy Method

Syntax format: window. moveBy (horizontal displacement, vertical displacement)

Function: Move the specified window according to the specified pixel parameter. The first parameter is the pixel that the window moves horizontally, and the second parameter is the pixel that the window moves vertically.

11. moveTo Method

Syntax format: window. moveTo (x, y)

Function: Move the window to the specified coordinate (x, y.

12. resizeBy Method

Syntax format: window. resizeBy (horizontal, vertical)

Function: changes the specified size (x, y) of the current window. If the value of x and y is greater than 0, it is extended and smaller than 0.

13. resizeTo Method

Syntax format: window. resizeTo (horizontal width, vertical width)

Function: changes the current window to (x, y), and x and y are respectively width and height.

14. scrollBy Method

Syntax format: window. scrollBy (horizontal displacement, vertical displacement)

Function: Scroll the content in the window according to the given displacement. If the parameter is positive, the system will scroll forward. Otherwise, the system will scroll backward.

15. scrollTo Method

Syntax format: window. scrollTo (x, y)

Function: Scroll the content in the window to the specified position.

16. find Method

Syntax format: window. find ()

Function: When this method is triggered, a "find" dialog box is displayed, allowing you to search for a string on the page that triggers the find method.

Note: This attribute is not supported in both IE5.5 and Netscape6.0.

17. back Method

Syntax format: window. back ()

Function: simulate a user clicking the "back" button on the browser to go to the previous page of the browser.

Note: This operation can be performed only when the current page has a previous page.

Note: IE5.5 does not support this method. Netscape6.0 supports this method.

18. forward Method

Syntax format: window. forward ()

Function: simulate a user clicking the "Forward" button on the browser to go to the next page of the browser.

Note: This operation can be performed only when the current page has a next page.

Note: IE5.5 does not support this method. Netscape6.0 supports this method.

19. home Method

Syntax format: window. home ()

Function: simulate a user clicking the "home" button on the browser to go to the specified page.

Note: IE5.5 does not support this method. Netscape6.0 supports this method.

20. stop Method

Syntax format: window. stop ()

Function: simulate a user clicking the "stop" button on the browser to terminate the download operation of the browser.

Note: IE5.5 does not support this method. Netscape6.0 supports this method.

21. print Method

Syntax format: window. print ()

Function: simulate a user clicking the print button on the browser to notify the browser to open the Print dialog box to print the current page.

22. blur method

Syntax format: window. blur ()

Function: removes focus from the window. Be careful when using the focus method, because the focus may be constantly moved in and out.

23. focus Method

Syntax format: window. focus ()

Function: focus in the window. When used with The blur method, be careful because the focus may be constantly moved in and out.

24. captureevent Method

Syntax format: window. captureevent (event)

Window. captureevent (Event 1 | event 2 |... | Event n)

Function: captures all events of a specified parameter. Programmers can define functions to process events as needed because they can capture events handled by local programs themselves. If multiple events need to be captured, the events are separated by the pipe character "|. The event types 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

25. enableexternalcapture event

Syntax format: window. enableexternalcapture (event)

Function: The enableexternalcapture method is used to capture external events passed in through parameters.

26. disableexternalcapture event

Syntax format: window. disableexternalcapture ()

Function: cancels the enableexternalcapture method and terminates the capture of external events.

27. handleevent event

Syntax format: window. handleevent (event)

Function: The Event processor that triggers the specified event.

28. releaseevent event

Syntax format: window. releaseevent (event)

Window. releaseevent (Event 1 | event 2 |... | Event n)

Function: release captured events passed in by parameters. These events are set by the window. captureevent method. The releasable events are the same as those of captureevent.

29. routeevent

Syntax format: window. releaseevent (event)

Function: transfers all captured events to the standard event handling method for handling. The events that can be transferred are the same as those of captureevent.

30. scroll event

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

Status statusbar. visible defaultstatus location locationbar. visible self name closed frames. length document history innerheight innerwidth menubar. visible opener outerheight outerwidth pagexoffset pageyoffset parent personalbar. visible scrollbar. visible toolbar. visible top

1. status attributes

Syntax format: window. status = string

Function: set or display the current status bar in the browser window.

Tip: You can use this property to set the browser window status bar information.

2. statusbar attributes

Syntax format: window. statusbar. Attribute

Function: The statusbar attribute is an object used to access its own visible attribute to determine whether the status bar is visible.

Note: ie5.5 does not support this attribute.

3. statusbar. visible attribute

Syntax format: window. statusbar. visible

Function: Check whether the status bar is visible. If visible, true is returned. Otherwise, false is returned.

Note: ie5.5 does not support this attribute.

4. defaultstatus attributes

Syntax format: window. defaultstatus [= string]

Function: The defaultstatus attribute value is the default display information of the status bar in the browser window.

5. location attribute

Syntax format: window. location = url

Function: Provides the url Information of the current window or specifies the url to open the window.

6. locationbar attributes

Syntax format: window. locationbar. Attribute

Function: The locationbar attribute can also be viewed as a sub-object. This attribute is used to obtain its own visible attribute to determine whether the location bar is visible. So far, this property has only one sub-attribute: visible.

Note: ie5.5 does not support this attribute.

7. locationbar. visible attribute

Syntax format: window. locationbar. visible

Function: whether the returned position bar is visible. If visible, true is returned. Otherwise, false is returned.

Note: ie5.5 does not support this attribute.

8. self attributes

Syntax format: window. self. Method

Window. self. Properties

Function: This property contains the flag of the current window. With this property, you can ensure that when multiple windows are opened, the functions or properties in the current window are correctly called without confusion.

9. name attributes

Syntax format: window. name = name

Function: return the window name, which is specified when the window. open () method creates a new window. In javascript1.0, this attribute can only be used to read the window name. In javascript1.1, you can use this attribute to specify a name for a window not created using the window. open () method.

10. closed attributes

Syntax format: window. closed

Function: The closed attribute is used to return whether the instance in the specified window is closed. If it is closed, true is returned, and flase is returned.

11. frames attributes

Syntax format: window. frames ["framework name"]

Window. frames [value]

Function: The frames attribute is an array used to store each sub-window (framework) instance created by an element in the document, the subscript can be a sequence number or a name specified by the name attribute of the frame element.

12. frames. length attribute

Syntax format: window. frames. length

Function: the frames. length attribute is used to show the number of subwindow (FRAME) instances in the document.

13. length attribute

Syntax format: window. length

Function: return the number of subwindows in a window. The value of this attribute is the same as that of window. frame. length.

14. document attributes

Syntax format: Too Many Doc ument. event too many Doc ument. method too many Doc ument. Attribute

Function: the sub-object document of the window object is the core object of javascript. An instance is created when the body element is encountered in the script.

15. history attributes

Syntax format: window. history [value] window. history. Method () window. history. Attribute

The window object sub-object history is one of the core javascript objects. This attribute contains an array of the names and URLs of accessed pages.

16. innerheight attribute

Syntax format: window. innerheight = Value

Function: return or specify the pixel height of the document in the browser window. This height does not include any toolbar or page modification height that makes up the window.

Note: ie5.5 does not support this attribute.

17. innerwidth attribute

Syntax format: window. innerheight = Value

Function: return or specify the pixel width of the document in the browser window. This width does not include the page width of any toolbar or window.

Note: ie5.5 does not support this attribute.

18. menubar attributes

Syntax format: window. menubar. Attribute

Function: the menubar attribute can also be viewed as a sub-object. This attribute is used to obtain its own visible attribute to determine whether the menu bar is visible. So far, this property has only one sub-attribute: visible.

Note: ie5.5 does not support this attribute.

19. menubar. visible attributes

Syntax format: window. menubar. visible

Function: the menubar. visible attribute is used to return whether the menu bar is visible. If visible, true is returned, and false is returned.

Note: ie5.5 does not support this attribute.

20. opener attributes

Syntax format: window. opener window. opener. Method window. opener. Attribute

Function: The opener attribute is associated with the parent window that opens the window. when accessing the operer attribute in the Child window, the parent window is returned. This attribute allows you to use methods and attributes in the parent window object.

21. outerheight attribute

Syntax format: window. outerheight

Function: The outerheight attribute is used to access the pixel height of the browser window, which includes the height of the toolbar and decorative edge.

Note: ie5.5 does not support this attribute.

22. outerwidth attribute

Syntax format: window. outerwidth

Function: The outerwidth attribute is used to access the pixel width of the browser window, which includes the width of the toolbar and decorative edge.

Note: ie5.5 does not support this attribute.

23. pagexoffset attribute

Syntax format: window. pagexoffset = Value

Function: Specify the current horizontal pixel position in the upper left corner of the document in the browser window. Before using moveto to move a window, you can use this attribute to determine whether to move the window. This attribute returns the current position of the visible document relative to the entire page.

Note: ie5.5 does not support this attribute.

24. pageyoffset attributes

Syntax format: window. pageyoffset = Value

Function: Specify the current vertical pixel position in the upper left corner of the document in the browser window. Before using moveto to move a window, you can use this attribute to determine whether to move the window. This attribute returns the current position of the visible document relative to the entire page.

Note: ie5.5 does not support this attribute.

25. parent attributes

Syntax format: window. parent. frames [value] window. parent. framesname

Function: access the parent window of each sub-window (Multi-frame.

26. personalbar attributes

Syntax format: window. personalbar. Attribute

Function: The personalbar attribute is also an object used to access its visible attribute to determine whether the personal bar is visible.

Note: ie5.5 does not support this attribute.

27. personalbar. visible attributes

Syntax format: window. personalbar. visible

Function: determines whether the personal column is visible. If visible, true is returned. Otherwise, false is returned.

Note: ie5.5 does not support this attribute.

28. scrollbars attributes

Syntax format: window. scrollbars. Attribute

Function: The scrollbars attribute is an object and is used to access its visible attribute to determine whether the scroll bar is visible.

Note: ie5.5 does not support this attribute.

29. scrollbars. visible attribute

Syntax format: window. scrollbars. visible

Function: scrollbars. visible is used to determine whether the scroll bar is visible. If visible, true is returned. Otherwise, false is returned.

Note: ie5.5 does not support this attribute.

30. toolbar attributes

Syntax format: window. toolbar. Attribute

Function: the toolbar attribute is an object used to access its own visible attribute to determine whether the toolbar is visible.

Note: ie5.5 does not support this attribute.

31. toolbar. visible attribute

Syntax format: window. toolbar. visible

Function: the toolbar. visible attribute is used to check whether the toolbar is visible. If visible, true is returned. Otherwise, false is returned.

Note: ie5.5 does not support this attribute.

32. top attributes

Syntax format: window. top. frames [value] window. top. framename window. top. Method ()

Window. top. Properties

Function: The top attribute of the window object is used to contain information about the top-level windows of all sub-Windows (Multi-frame) loaded into the browser.

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.