Home > Web Front-end > JS Tutorial > body text

Javascript window object attribute sorting_basic knowledge

WBOY
Release: 2016-05-16 18:43:32
Original
861 people have browsed it

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: Open a new window and load the web page 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;
The open method can also be used when opening a new browser window. Specify the name of the window (the second parameter); The
open method can also specify the style of the window (the third parameter) when opening a new browser window.
The window style has the following options. These options Multiple selections are possible. If multiple selections are made, separate the options with commas:
toolbar: Specify 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 value and meaning of the option are the same as toolbar;
directories: specifies whether the window has a link toolbar, the value and meaning of the option are the same as toolbar;
status: specifies whether the window has a status bar, the value and meaning of the option are the same as toolbar Same;
menubar: specifies whether the window has a menu, the value and meaning of the option are the same as toolbar;
scrollbar: specifies whether there is a scroll bar when the current window document is larger than the window, the value and meaning of the option are the same as
toolbar ;
resizable: specifies whether the window can be resized. The value and meaning of the option are the same as toolbar;
width: specifies the width of the window in pixels, which has been replaced by innerWidth;
height: in pixels Specifies the height of the window, which has been replaced by innerHeight;
outerWidth: specifies the outer width of the window in pixels;
outerHeight: specifies the outer height of the window in pixels;
left: specifies in pixels The position of the window from the left side of the screen;
top: Specifies 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 toolbar;
alwaysRaised : Specifies that the window floats on top of all windows. The value and meaning of the option are the same as toolbar;
dependent: Specifies that the opened window is a child window of the current window and will be
closed when the parent window is closed. Option The value and meaning of are the same as toolbar;
hotkeys: Set the hotkey for safe exit in a new window without menu bar. The value and meaning of the option are the same as
toolbar;
innerHeight: Set the document in the window pixel height;
innerWidth: set the pixel width of the document in the window;
screenX: set the pixel length of the window from the left edge of the screen;
screenY: set the pixel length of the window from the upper edge of the screen;
titleBar: Indicates whether the title bar is visible in the new window. The value and meaning of the option are the same as toolbar;
z-look: Indicates that when the window is activated, it cannot float above other windows. The value of the option and The meaning is the same as
toolbar.
The open method returns a reference to the window.
Tips: This method is often used to automatically open another window when opening a web page.
Example 6-2-1: Prepare a small program that is used to automatically open another window when the current window is opened. It is required that the window does not have a standard toolbar, address bar, link toolbar, or menu bar, but has status. column, the address of the webpage opened
in the window is: http://www.jb51.net.
2. close method
Syntax format:
window.close()
Function: The close method is used to automatically close the browser window.
3. alert method
Grammar format:
window.alert (prompt string)
Function: Pop up a warning box and display the prompt string text in the warning box.
4. confirm method
Syntax format:
window.confirm (prompt string)
Function: Display a confirmation box, display the prompt string in the confirmation box, when the user clicks "OK" This method returns true when the button
is clicked and false when "Cancel" is clicked.
5. prompt method
Grammar format:
window.prompt (prompt string, default text)
Function: Display an input box, display the prompt string in the input box, and enter the text The box displays the default text
and waits for user input. When the user clicks the "OK" button, the string entered by the user is returned. When
clicks the "Cancel" button, a null value is returned.
6. setTimeout method
Grammar format:
window.setTimeout (code character expression, milliseconds)
Function: Timing 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: Cancel the previous timing setting, and the parameter is the return value when set with setTimeout.
8. setInterval method
Syntax format:
window.setInterval (code character expression, milliseconds)
Function: After setting a time interval (second parameter), repeatedly execute the "code "Character expression" content
9. clearInterval method
Syntax format:
window.clearInterval (time intervaler)
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 by which the window moves horizontally, and the second parameter is the pixel by which the window moves vertically.
11.moveTo method
Syntax format:
window.moveTo(x,y)
Function: Move the window to the specified 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 values ​​of x and y are greater than 0 When it is expanded, when it is less than 0,
is reduced.
13. resizeTo method
Syntax format:
window.resizeTo(horizontal width, vertical width)
Function: Change the current window to (x, y) size, x, y are the width and high.
14. scrollBy method
Syntax format:
window.scrollBy (horizontal displacement, vertical displacement)
Function: Scroll the content in the window according to the given displacement. When the parameter is a positive number, it scrolls in the forward direction, otherwise it scrolls in the reverse
direction.
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 window will pop up and allow the user to touch
Search for a string in the page using the find method.
Note: This attribute is not supported in IE5.5 and Netscape6.0.
17. back method
Syntax format:
window.back()
Function: Simulate the user clicking 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 Netscape6.0 does.
18. forward method
Syntax format:
window.forward()
Function: Simulate the user clicking 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 Netscape6.0 does.
19. home method
Syntax format:
window.home()
Function: Simulate the user clicking the "Home" button on the browser to redirect the page to the specified page.
Note: IE5.5 does not support this method, but Netscape6.0 does.
20. stop method
Syntax format:
window.stop()
Function: Simulate the user clicking the "Stop" button on the browser to terminate the browser's download operation.
Note: IE5.5 does not support this method, but Netscape6.0 does.
21. print method
Syntax format:
window.print()
Function: Simulate the user clicking the "Print" button on the browser, notifying the browser to open the print dialog box to print
the current Page.
22. blur method
Syntax format:
window.blur()
Function: Remove focus from the window. Care must be taken when used with the focus method, as this may cause the focus
to continually move in and out.
23. focus method
Syntax format:
window.focus()
Function: Get focus on the window. You must be careful when using it with 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 with specified parameters. Because of the ability to capture events
that are handled by the local program itself, programmers can freely define functions to handle events. If there are multiple events that need to be captured, use the pipe character "|" to separate each event
. 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: Cancel the setting of the enableexternalcapture method and terminate the capture of external events.
27. handleevent event
Syntax format:
window.handleevent(event)
Function: Event handler that triggers the specified event.
28. releaseevent event
Grammar format:
window.releaseevent(event)
window.releaseevent(event1|event2|...|eventn)
Function: release through parameters Incoming captured events, these events are set by the
window.captureevent method, and the releasable events are the same as captureevent.
29. routeevent event
Grammar format:
window.releaseevent(event)
Function: Transfer all events of the captured type to the standard event processing method for processing, transferable things
The file is the same as captureevent.
30 scroll event
Syntax format:
window.scroll(x coordinate, y coordinate)
Function: Move the window to the specified coordinate position.
6-2-2 Attributes of the window object
The window object has the following attributes:
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 attribute
Grammar format:
window.status=string
Function: Set or give the status bar in the browser window of currently displayed information.
Tips: You can use this attribute to set the browser window status bar information.
2. statusbar attribute
syntax format:
window.statusbar. attribute
function: the statusbar attribute itself is also an object, 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, it returns true, otherwise it returns 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
Grammar format:
window.locationbar. attribute
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 property has only one sub-property: 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.Attribute
Function: This attribute contains the flag of the current window. Using this attribute, you can ensure that When a window
is opened, the functions or properties in the current window are correctly called without confusion.
9. name attribute
Syntax format:
window.name=name
Function: Return the window name, which is given when the window.open() method creates a new window.
In the javascript1.0 version, this attribute can only be used to read the window name. In the
javascript1.1 version, you can use this attribute to give a The window is given a name.
10. closed attribute
Grammar format:
window.closed
Function: The closed attribute is used to return whether the instance of the specified window has been closed. If it is closed, it returns true
, otherwise it returns false.
11. frames attribute
Syntax format:
window.frames["frame name"]
window.frames[value]
Function: The frames attribute is an array, used to store the document For each child window (frame
frame) instance created by the element, the subscript can be either the sequence number or the name
specified with the name attribute of the frame element to get and use it.
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
Grammar format:
window.length
Function: The length attribute returns the number of sub-windows in a window. This attribute has the same value as the
window.frame.length attribute .
14. document attribute
Syntax format:
window.document.Event
window.document.Method
window.document.Attribute
Function: The sub-object document of the window object is javascript The core object, an instance is created when the
body element is encountered in the script.
15. History attribute
Syntax format:
window.history[value]
window.history.Method()
window.history.Attribute
The sub-object history of the window object is One of the core objects of JavaScript, this attribute contains an
array of names and URLs of visited pages.
16. innerheight attribute
Syntax format:
window.innerheight=numeric value
Function: Return or specify the pixel height of the document in the browser window. This height does not include any toolbars and
components The page decoration height of the window.
Note: IE5.5 does not support this attribute.
17. innerwidth attribute
Syntax format:
window.innerheight=numeric value
Function: Return or specify the pixel width of the document in the browser window. This width does not include any toolbars and
components The page decoration width of the window.
Note: IE5.5 does not support this attribute.
18. menubar attribute
syntax format:
window.menubar. attribute
function: 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 property has only one sub-property: visible.
Note: IE5.5 does not support this attribute.
19. menubar.visible attribute
Syntax format:
window.menubar.visible
Function: menubar.visible attribute is used to return whether the menu bar is visible. If it is visible, it returns true, otherwise
Return 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 related to the parent window that opens the window Contact, when accessing the operator attribute in the child window
, the parent window is returned. This property provides access to methods and properties from 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 toolbars and decorations.
Note: IE5.5 does not support this attribute.
23. pagexoffset attribute
Syntax format:
window.pagexoffset=numeric value
Function: Specify the current horizontal pixel position of the upper left corner of the document in the browser window in the window. Before using
moveto to move, you can use this attribute to decide whether the window needs to be moved. Because 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=numeric value
Function: Specify the current vertical pixel position of the upper left corner of the document in the browser window in the window. Before using
moveto to move, you can use this attribute to decide whether the window needs to be moved. Because 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[numeric value]
window.parent.framesname
Function: access the parent window where each child window (multi-frame) is located.
26. personalbar attribute
syntax format:
window.personalbar. attribute
function: the personalbar attribute itself is also an object, 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: Determine whether the personal bar 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.property
function: the scrollbars attribute itself is also an object, 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
Return false.
Note: IE5.5 does not support this attribute.
30. toolbar attribute
syntax format:
window.toolbar. attribute
function: the toolbar attribute itself 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 property
Syntax format:
window.toolbar.visible
Function: toolbar.visible property is used to check whether the toolbar is visible. If it is visible, it returns true.
Vice versa. Return 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 information about the topmost window of all sub-windows (multi-frames) loaded into the browser.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!