Browser Window Properties

web front end nine thousand six hundred and seventeen 13 years ago (2011-11-15)

Window object properties


Proficient in the use of open, close, alert, confirm, prompt, setTimeout, clearTimeout, setInterval, clearInterval, moveBy, resizeBy, and scrollBy methods of window objects


Master the use of moveTo, resizeTo, scrollTo, and print methods of window objects


Master the use of status, location, name, self, and opener attributes of window objects


The Window object is one of the highest level objects of client-side javascript browser Window. No matter whether there is an open web page in the window, when the BODY, FRAMESET or FRAME element is encountered, an instance of the window object will be automatically created. In addition, the instance of this object can also be created by the window. open () method. Since the window object is the common ancestor of most other objects, the reference of the window object can be omitted when calling the methods and properties of the window object. For example, window. document. write() can be abbreviated as document. write(). The instance name of the window can be omitted when publishing any method and property of the window object in the window. For example, when setting the status attribute for the current myWin window, you can use only status instead of myWin.status. However, you must use the instance name when calling the location attribute, close() method, or open() method in event processing.  

Method of window object


The window object has the following methods:

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.  


Description:


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


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


The open method can also specify the window style (the third parameter) when opening a new browser window

The window style has the following options, which can be multiple choices. If multiple choices are selected, 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, it means there is a standard toolbar; when the value of this option is 0 or no, it means there is no standard toolbar;  


Location: specifies whether the window has an address toolbar. The values and meanings of the options are the same as those of toolbar;  


Directories: specifies whether the window has a link toolbar, and the values and meanings of the options are the same as those of toolbar;  


Status: specifies whether the window has a status bar. The values and meanings of options are the same as those of toolbar;  


Menubar: specifies whether the window has a menu. The values and meanings of options are the same as those of toolbar;  


Scroll bar: specifies whether there is a scroll bar when the current window document is larger than the window. The value and meaning of options are the same as that of toolbar;  


Resizable: specifies whether the window can be resized. The values and meanings of the options are the same as those of 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: specify the external height of the window in pixels;  


Left: specify the position of the window from 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, and the value and meaning of the option are the same as those of toolbar;  


AlwaysRaised: specifies that the window floats above all windows, and the value and meaning of the option are the same as those of toolbar;  


Dependent: specifies that the open window is a child window of the current window and closes with the closing of the parent window. The value and meaning of the option are the same as those of toolbar;


Hotkeys: set the hot key for safe exit in a new window without a menu bar. The value and meaning of the option are the same as those of toolbar;


InnerHeight: set the pixel height of the document in the window;


InnerWidth: set the pixel width of the document in the window;  


ScreenX: set the pixel length from the window to the left edge of the screen;


ScreenY: set the pixel length from the window to the screen upper boundary;


TitleBar: indicates whether the title bar is visible in the new window. The value and meaning of the option are the same as those of toolbar;


Z-book: indicates that when a window is activated, it cannot float above other windows. The value and meaning of the option are the same as those of toolbar.


The open method returns a reference to the window.


Tip: This method is often used to automatically open another window when opening a web page.


For example, prepare a small program to automatically open another window when the current window is opened. The window is required to have no standard toolbar, address bar, link toolbar, menu bar, but a status bar.  

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 will pop up and prompt string text will be displayed in the warning box.


4. Confirm method


Syntax format:


Window. confirm (prompt string)


Function: A confirmation box is displayed, in which a prompt string is displayed. This method returns true when the user clicks OK, and false when the user clicks Cancel.  

5. Prompt method


Syntax format:


Window.prompt (prompt string, default text)


Function: display an input box, display prompt string in the input box, display default text in the input text box, and wait for user input. When the user clicks OK, return the string entered by the user, and when the user clicks Cancel, return null value.  

6. SetTimeout method


Syntax format:


Window. setTimeout (code character expression, milliseconds)


Function: set the timing. When the specified number of milliseconds is reached, the code character expression will be automatically executed.


7. clearTimeout method


Syntax format:


Window. clearTimeout (timer)


Function: Cancel the previous timing settings. The parameters are the return values when setting with setTimeout.


8. setInterval method


Syntax format:

Window. setInterval (code character expression, milliseconds)


Function: after setting a time interval (the second parameter), repeatedly execute the content of "code character expression"

9. clearInterval method


Syntax format:

Window.clearInterval (time interval)


Function: cancel the timing set by setInterval. 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 given pixel parameters. The first parameter is the pixel where the window moves horizontally

The two parameters are the pixels that the window moves vertically.  

11. moveTo method


Syntax format:

window.moveTo(x,y)


Function: move the window to the specified coordinates (x, y).  

12. resizeBy method


Syntax format:

Window.resizeBy (horizontal, vertical)


Function: change the current window to the specified size (x, y). When the value of x and y is greater than 0, it is expanded; when the value is less than 0, it is reduced.  

13. resizeTo method


Syntax format:

Window.resizeTo (horizontal width, vertical width)


Function: change the size of the current window to (x, y), where x and y are width and height respectively.  

14. scrollBy method


Syntax format:

Window.scrollBy (horizontal displacement, vertical displacement)


Function: scroll the contents of the window according to the given displacement. When the parameter is a positive number, it will scroll in the forward direction, otherwise it will scroll in the reverse direction.  

15. scrollTo method


Syntax format:

window.scrollTo(x,y)


Function: scroll 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 will pop up and allow the user to find a string on the page where the find method is triggered.  

Note: This attribute is not supported in IE5.5 and Netscape 6.0.  

17. Back method


Syntax format:

window.back()


Function: Simulate the user to click the "Back" button on the browser to move the page to the previous page of the browser. Note: This operation can only be performed when the current page has a previous page.  

Note: IE5.5 does not support this method, but Netscape 6.0 does.  

18. Forward method


Syntax format:

window.forward()


Function: Simulate the user to click the "Forward" button on the browser to move the page to the next page of the browser.  

Note: This operation can only be performed when the next page exists on the current page.  

Note: IE5.5 does not support this method, but Netscape 6.0 does.  

19. home method


Syntax format:

window.home()


Function: Simulate the user to click the "Home" button on the browser to move the page to the specified page.  

Note: IE5.5 does not support this method, but Netscape 6.0 does.  

20. Stop method


Syntax format:

window.stop()


Function: Simulate the user to click the "Stop" button on the browser to terminate the download operation of the browser.  

Note: IE5.5 does not support this method, but Netscape 6.0 does.  

21. Print method


Syntax format:


window.print()


Function: Simulate the user to click the "Print" button on the browser, and notify the browser to open the print dialog box to print the current page.

22. blur method


Syntax format:


window.blur()


Function: Move the focus from the window. You must be careful when using the focus method, because it may cause the focus to move in and out continuously.


23. Focus method


Syntax format:


window.focus()


Function: focus the window. Be careful when using the blur method, because it may cause the focus to move in and out continuously.  


24. captureevent method


Syntax format:

window.captureevent(event) 


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


Function: capture all events of specified parameters. Because it can capture which events are handled by the local program itself, the programmer can freely define functions to handle events. If multiple events need to be captured, separate them with the pipe character "|". 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.mou SEO ut 

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: Cancel the setting of the enableexternalcapture method and terminate the capture of external events.  

27. Handleevent event


Syntax format:

window.handleevent(event)


Function: the event handler 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 through parameters. These events are set by the window.captureevent method. The events that can be released are the same as captureevent.  

29. Routeevent Event


Syntax format:

window.releaseevent(event)


Function: transfer all events of the captured type to the standard event processing method for processing. The events that can be transferred are the same as captureevent.  

30 scroll event


Syntax format:

Window.scroll (x coordinate, y coordinate)


Function: move the window to the specified coordinate position.  

Properties of the window object


The window object has the following properties:

1. Status attribute


Syntax format:

Window. status=String


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

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

2. statusbar attribute


Syntax format:

Window.statusbar. property


Function: The statusbar attribute itself is an object, which is used to access its own visible attribute to determine whether the status bar is visible. Note: ie5.5 browser does not support this attribute.  

3. statusbar.visible attribute


Syntax format:

window.statusbar.visible


Function: check whether the status bar is visible. If it is visible, return true. Otherwise, return false. Note: ie5.5 browser does not support this attribute.  

4. Defaultstatus attribute


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: give the url information of the current window or specify the url of the open window.  

6. Locationbar attribute


Syntax format:

Property window.locationbar


Function: The locationbar attribute can also be regarded 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 attribute has only one child attribute: visible. Note: ie5.5 does not support this attribute.  

7. Locationbar.visible attribute


Syntax format:

window.locationbar.visible


Function: returns whether the location bar is visible. If it is visible, it returns true. Otherwise, it returns false. Note: ie5.5 does not support this attribute.  

8. Self attribute


Syntax format:

Window.self. method


Window.self. property


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

9. name attribute


Syntax format:

Window. name=Name


Function: returns the window name, which is given by the window. open() method when creating a new window. In version 1.0 of javascript, this attribute can only be used to read the window name. In version 1.1 of javascript, this attribute can be used to specify a name for a window not created with the window. open() method.  

10. Closed attribute


Syntax format:

window.closed


Function: The closed attribute returns whether the instance of the specified window has been closed. If it is closed, it returns true. Otherwise, it returns flat.  

11. Frames attribute


Syntax format:

Window. frames ["Frame name"]


Window. frames [value]


Function: The frames attribute is an array, which is used to store every sub window (frame) instance created by the element in the document. The subscript can be either the sub serial number or the 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 give the number of sub window (frame) instances in the document.  

13. Length attribute


Syntax format:

window.length


Function: The length attribute returns the number of child windows in a window. This attribute has the same value as the window.frame.length attribute.  

14. Document attribute


Syntax format:

Event of window.document


Window.document. method


Window.document. property


Function: The sub object document of the window object is the core object of javascript script Create an instance when the body element is encountered in.  

15. History attribute


Syntax format:

Window. history [Value]


Window. history. method ()


Window.history. Properties


The sub object history of the window object is one of the core objects of javascript. This attribute contains an array of the names and urls of the visited 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 the height of any toolbar and page decoration of the constituent 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, which does not include any toolbar and page decoration width of the constituent window. Note: ie5.5 does not support this attribute.  

18. menubar attribute


Syntax format:

Window.menubar. property


Function: The menubar attribute can also be regarded 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 attribute has only one child attribute: visible. Note: ie5.5 does not support this attribute.  

19. menubar.visible attribute


Syntax format:

window.menubar.visible


Function: The menubar.visible attribute is used to return whether the menu bar is visible. If it is visible, it returns true. Otherwise, it returns false. Note: ie5.5 does not support this attribute.  

20. opener attribute


Syntax format:

window.opener


Window. opener. method


Window.opener.property


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 property allows you to use methods and properties 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 edges. 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 edges. Note: ie5.5 does not support this attribute.  

23. Pagexoffset attribute


Syntax format:

Window. pagexoffset=Value


Function: specify the current horizontal pixel position of the upper left corner of the document in the browser window. Before moving with moveto, you can use this attribute to decide 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 attribute


Syntax format:

Window. pageyoffset=Value


Function: specify the current vertical pixel position of the upper left corner of the document in the browser window. Before moving with moveto, you can use this attribute to decide 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 attribute


Syntax format:

Window. parent. frames [value]


window.parent.framesname


Function: access the parent window of each child window (multi frame).  

26. personalbar attribute


Syntax format:

Window.personalbar. property


Function: The personalbar attribute itself is an object, which is used to access its own visible attribute to determine whether the personal bar is visible. Note: ie5.5 does not support this attribute.  

27. personalbar.visible attribute


Syntax format:

window.personalbar.visible


Function: determines whether the personal column is visible. If it is visible, it returns true. Otherwise, it returns false. Note: ie5.5 does not support this attribute.  

28. Scrollbars attribute


Syntax format:

Window.scrollbars. Properties


Function: The scrollbars attribute itself is an object, which is used to access its own 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 it is visible, it returns true. Otherwise, it returns false. Note: ie5.5 does not support this attribute.  

30. Toolbar attribute


Syntax format:

Property window.toolbar


Function: The toolbar attribute itself is an object, which is 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 property is used to check whether the toolbar is visible. If it is visible, it returns true. Otherwise, it returns false. Note: ie5.5 does not support this attribute.  

32. Top attribute


Syntax format:

Window. top. frames [value]


window.top.framename


Window. top. method ()


Window.top. property


Function: The top attribute of the window object is used to contain the information of the topmost window of all child windows (multi frames) loaded into the browser