JavaScript Window browser object model method and attribute summary, window Object Model

Source: Internet
Author: User

JavaScript Window browser object model method and attribute summary, window Object Model

Window object

All browsers support window objects. It indicates the browser window.

All JavaScript global objects, functions, and variables are automatically members of the window object.

The global variable is the property of the window object.

Global functions are the methods of window objects.

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 ),
Window style has the following options. You can select multiple options. If you select multiple options, use commas to separate them:
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. A prompt string is displayed in the confirmation box. When you click OK
This method returns true, and false if 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.
And wait for the user to enter. When the user clicks the "OK" button, the string entered by the user is returned.
When 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.
The two parameters are the pixels that move vertically in the window.

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 values of x and y are greater than 0, they are extended and smaller than 0.
To narrow down.

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 a positive number, it will scroll forward. Otherwise, reverse
Scroll.

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
Find a string on the page of 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: simulates the user's clicking the "print" button on the browser to notify the browser to open the Print dialog box and print it.
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 caused.
Constantly move in and out.

23. focus Method

Syntax format:
Window. focus ()
Function: focus in the window. Be careful when used with The blur method, because the focus may be less
Break forward and remove.

24. captureEvent Method

Syntax format:
Window. captureEvent (Event)
Window. captureEvent (Event 1 | event 2 |... | event n)
Function: captures all events of a specified parameter. Events that can be captured by the local program itself
So programmers can define functions at will to process events. If multiple events need to be captured
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: releases captured events passed in through parameters.
The event that can be released is the same as that set by the window. captureEvent method.

29. routeEvent

Syntax format:
Window. releaseEvent (event)
Function: transfers all captured events to standard event handling methods for handling, and events that can be transferred.
The same as captureEvent.

30 scroll events

Syntax format:
Window. scroll (X coordinate, Y coordinate)
Function: moves the window to the specified coordinate position.

The window object has the following attributes:

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. Properties
Function: The statusbar attribute is also an object used to access its own visible attribute to ensure
Determines 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. Properties
Function: The locationbar attribute can also be viewed as a sub-object, which is used to obtain its own
To determine whether the position 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, it can be opened in multiple windows.
In this case, correctly calling the functions or properties in the current window will not cause 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 window names.
When using javascript1.1, you can use this attribute to create
Window to specify a name.

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.
Otherwise, 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 created by an element in the document (Box
Rack) instance. 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: returns the number of subwindows in a window.
The values of the window. frame. length attribute are the same.

14. document attributes

Syntax format:
Window.doc ument. Event
Window.doc ument. Method
Specified parameter Doc ument. Attribute
Function: the sub-object document of the window object is the core object of javascript.
Create an instance when the BODY element is created.

15. history attributes

Syntax format:
Window. history [value]
Window. history. Method ()
Window. history. Properties
The window object sub-object history is one of the core javascript objects. This property contains
List of the names and URLs of the accessed pages.

16. innerHeight attribute

Syntax format:
Window. innerHeight = Value
Function: return or specify the pixel height of the document in the browser window, which does not include any toolbar or
The page height of 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 any toolbar or
The page decoration width of the 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 child object. This attribute is used to obtain its own
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 yes, true is returned.
Returns false.
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 you access the operer attribute in the subwindow
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 a browser window, which includes the toolbar and
The height of the 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 toolbar and
The width of the trim.
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. Under Exploitation
Before moving moveTo, you can use this attribute to determine whether to move the window. Because this attribute returns
You can see the current position of the 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. Under Exploitation
Before moving moveTo, you can use this attribute to determine whether to move the window. Because this attribute returns
You can see the current position of the 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. Properties
Function: The personalbar attribute is also an object used to access its own visible attribute.
Determines whether the personal column 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. Properties
Function: The scrollbars attribute is an object and is used to access its visible attribute.
Determines 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.
Returns false.
Note: IE5.5 does not support this attribute.

30. toolbar attributes

Syntax format:
Window. toolbar. Properties
Function: the toolbar attribute is also 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.

The above is all the content of this article. I hope you will like it.

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.