DOM Window

Window Object

The Window object represents the browser window. A Window object is created automatically with every instance of a <body> or <frame> tag.

IE: Internet Explorer, F: Firefox, N: Netscape, W3C: World Wide Web Consortium (Internet Standard).

Window Object Collections

CollectionDescriptionIEFNW3C
frames[]Returns all named frames in the window312 

Window Object Objects

ObjectDescriptionIE FNW3C
clientInformationContains information about the browser4   
clipboardData 5   
documentThis object can be used to access all elements in a page3   
eventRepresents the state of an event4   
external 4   
historyContains the URLs the user has visited within a browser window3   
locationContains the current URL of the window3   
navigatorContains information about the client browser3   
screenContains information about the client's display screen4   

Window Object Properties

PropertyDescriptionIE FNW3C
closedReturns a Boolean value that specifies whether the referenced window has been closed413 
defaultStatusSets or returns the default text in the statusbar of the windows (will be displayed when the page loads)312 
dialogArgumentsReturns all variables passed into the modal dialog window4   
dialogHeightSets or returns the height of the modal dialog window4   
dialogLeftSets or returns the left coordinates of the modal dialog window4   
dialogTopSets or returns the top coordinates of the modal dialog window4   
dialogWidthSets or returns the width of the modal dialog window4   
frameElementReturns the frame/iframe object that is hosting the window in the parent document5   
lengthSets or returns the number of frames in the window416 
nameSets or returns the name of the window312 
offscreenBufferingSets or returns a Boolean value that specifies whether the window is drawn offscreen before being visible to the user4   
openerSets or returns a reference to the window that created the window413 
parentReturns the parent window312 
returnValueSets or returns the value returned from the modal dialog window4   
screenLeftReturns the x-coordinate of the upper left corner of the browser - relative to the upper left corner of the screen5   
screenTopReturns the y-coordinate of the top corner of the browser - relative to the top corner of the screen5   
selfReturns a reference to the current window312 
statusSets or returns the text in the statusbar of the window312 
topReturns the topmost ancestor window312 

Window Object Methods

MethodDescriptionIEFNW3C
alert()Displays an alert box with a specified message and an OK button312 
attachEvent("event",pointer) 5   
blur()Removes focus from the current window413 
clearInterval(ID)Cancels a timeout that is set with the setInterval() method414 
clearTimeout(ID)Cancels a timeout that is set with the setTimeout() method312 
close()Closes the current window312 
confirm()Displays a dialog box with a specified message and an OK and a Cancel button312 
createPopup()Creates a pop-up window5   
execScript("code", "lang")

Executes a specified script. The arguments can take the following values:

codeRequired. The code to be executed
langRequired. JScript | VBScript | JavaScript

4   
focus()Sets focus on the current window413 
moveBy(x,y)Moves the window a specified number of pixels in relation to its current co-ordinates414 
moveTo(x,y)Moves the window's left and top edge to the specified co-ordinates414 
navigate("URL")Loads the specified URL into the window3   
open()Opens a new browser window3   
print()Prints the contents of the current window514 
prompt()

Displays a dialog box that prompts the user for input

312 
resizeBy()Resizes the window by the specified pixels4   
resizeTo()Resizes the window to the specified width and height41.5  
scroll()Deprecated. Use scrollTo() instead4   
scrollBy()Scrolls the content by the specified number of pixels414 
scrollTo()Scrolls the content to the specified coordinates414 
setActive() 5   
setInterval(code, millisec[, "lang"])

Calls a function / evaluate an expression every time a specified interval (in milliseconds) has been reached. The arguments can take the following values:

codeRequired. A pointer to a function or the code to be executed
millisecRequired. The number of milliseconds
langOptional. JScript | VBScript | JavaScript

414 
setTimeout()

Calls a function or evaluates an expression after a specified number of milliseconds

312 
showHelp("URL"[, contextID])

Displays a Help file (must be of type .htm or .chm). When using this method, a second Help box appears when pressing F1 or when clicking Help on the menu bar. To prevent the default Help box from appearing set returnValue to false. The arguments can take the following values:

URLRequired. The URL of a Help file
contextIDOptional. A string or integer that specifies a context identifier in the Help file

4   
showModalDialog("URL"[, args, "list"])Loads a URL in a modal dialog box. A modal dialog box retains focus while open. The user CANNOT switch windows until the dialog box is closed. The arguments can take the following values:

"URL" - Required. The URL of the document to display.

args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object.

"list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:

dialogHeight : numberthe height* of the dialog window
dialogLeft : numberthe left position of the dialog window
dialogTop : numberthe top position of the dialog window
dialogWidth : numberthe width* of the dialog window
center : yes | no | 1 | 0 | on | offwhether to center the dialog window within the desktop. Default is yes
dialogHide : yes | no | 1 | 0 | on | offwhether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
edge : sunken | raisedthe edge style of the dialog window. Default is raised
help : yes | no | 1 | 0 | on | offwhether the dialog window displays the Help icon. Default is yes
resizable : yes | no | 1 | 0 | on | offwhether the dialog window is resizable. Default is no
scroll : yes | no | 1 | 0 | on | offwhether the dialog window displays scrollbars. Default is yes
status : yes | no | 1 | 0 | on | offwhether the dialog window displays a status bar. Default is yes for untrusted dialog windows and no for trusted dialog windows
unadorned : yes | no | 1 | 0 | on | offwhether the dialog window displays the border window chrome. Only available when a dialog window is opened from a trusted application. Default is no

4   
showModelessDialog("URL"[, args, "list"])Loads a URL in a modeless dialog box. The modeless dialog box displays even when the user switches focus to another window (useful for menus and Help systems). The arguments can take the following values:

"URL" - Required. The URL of the document to display.

args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object.

"list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:

dialogHeight : numberthe height* of the dialog window
dialogLeft : numberthe left position of the dialog window
dialogTop : numberthe top position of the dialog window
dialogWidth : numberthe width* of the dialog window
center : yes | no | 1 | 0 | on | offwhether to center the dialog window within the desktop. Default is yes
dialogHide : yes | no | 1 | 0 | on | offwhether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
edge : sunken | raisedthe edge style of the dialog window. Default is raised
help : yes | no | 1 | 0 | on | offwhether the dialog window displays the Help icon. Default is yes
resizable : yes | no | 1 | 0 | on | offwhether the dialog window is resizable. Default is no
scroll : yes | no | 1 | 0 | on | offwhether the dialog window displays scrollbars. Default is yes
status : yes | no | 1 | 0 | on | offwhether the dialog window displays a status bar. Default is yes for untrusted dialog windows and no for trusted dialog windows
unadorned : yes | no | 1 | 0 | on | offwhether the dialog window displays the border window chrome. Only available when a dialog window is opened from a trusted application. Default is no

5   

* The default unit of measure for dialogHeight and dialogWidth in IE4 is em; in IE5 it is px. Other values to use: cm, mm, in, pt, pc, or ex. For consistent results, use px! Note: The min. dialogHeight you can specify is 100px.

Window Object Events

Syntax: window.event_name="someJavaScriptCode"

EventDescriptionIEFNW3C
onBlurExecutes some code when a Blur event occurs 13 
onErrorExecutes some code when an Error event occurs 13 
onFocusExecutes some code when a Focus event occurs 13 
onLoadExecutes some code when an Load event occurs 12 
onResizeExecutes some code when a Resize event occurs 14 
onUnloadExecutes some code when an Unload event occurs 12 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值