当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > DOM Window 对象

HTML DOM
DOM TableRow 对象
DOM Textarea 对象
DOM Window 对象

HTML DOM 中的 DOM Window 对象


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 762 ::
收藏到网摘: n/a

Window 对象

The Window object represents the browser window. A Window object is created automatically with every instance of a <body> or <frame> tag.
window对象代表了浏览器的窗口。每当窗口含有<body>或是<frame>标签就会自动建立window对象

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

Window 对象集合

Collection
集合
Description
描述
IE F N W3C
frames[] Returns all named frames in the window
返回在window中所有命名过的框架
3 1 2  

Window object对象

Object Description
描述
IE  F N W3C
clientInformation Contains information about the browser
包含有关浏览器的信息
4      
clipboardData   5      
document This object can be used to access all elements in a page
这个对象可以用来访问在页面中的所有元素
3      
event Represents the state of an event
某个事件的状态
4      
external   4      
history Contains the URLs the user has visited within a browser window
包含用户在浏览器窗口中所有已经访问过的URL
3      
location Contains the current URL of the window
包含了当前窗口的URL
3      
navigator Contains information about the client browser
包含了有关客户端浏览器的信息
3      
screen Contains information about the client's display screen
包含了有关客户端显示屏幕的信息
4      

Window 对象属性

Property
属性
Description
描述
IE  F N W3C
closed Returns a Boolean value that specifies whether the referenced window has been closed
获取引用窗口是否已关闭。
4 1 3  
defaultStatus Sets or returns the default text in the statusbar of the windows (will be displayed when the page loads)
设置或获取要在窗口底部的状态栏上显示的缺省信息。
3 1 2  
dialogArguments Returns all variables passed into the modal dialog window
设置或获取传递给模式对话框窗口的变量或变量数组。
4      
dialogHeight Sets or returns the height of the modal dialog window
设置或获取模式对话框的高度。
4      
dialogLeft Sets or returns the left coordinates of the modal dialog window
设置或获取模式对话框的左坐标。
4      
dialogTop Sets or returns the top coordinates of the modal dialog window
设置或获取模式对话框的顶坐标。
4      
dialogWidth Sets or returns the width of the modal dialog window
设置或获取模式对话框的宽度。
4      
frameElement Returns the frame/iframe object that is hosting the window in the parent document
获取在父文档中生成 window 的 frame 或 iframe 对象。
5      
length Sets or returns the number of frames in the window
设置或获取集合中对象的数目。
4 1 6  
name Sets or returns the name of the window
设置或获取表明窗口名称的值。
3 1 2  
offscreenBuffering Sets or returns a Boolean value that specifies whether the window is drawn offscreen before being visible to the user
设置或获取对象在对用户可见之前是否要先在屏幕外绘制。
4      
opener Sets or returns a reference to the window that created the window
设置或获取创建当前窗口的窗口的引用。
4 1 3  
parent Returns the parent window
获取对象层次中的父窗口。
3 1 2  
returnValue Sets or returns the value returned from the modal dialog window
设置或获取从模式对话框返回的值。
4      
screenLeft Returns the x-coordinate of the upper left corner of the browser - relative to the upper left corner of the screen
获取浏览器客户区左上角相对于屏幕左上角的 x 坐标。
5      
screenTop Returns the y-coordinate of the top corner of the browser - relative to the top corner of the screen
获取浏览器客户区左上角相对于屏幕左上角的 y 坐标。
5      
self Returns a reference to the current window
获取对当前窗口或框架的引用。
3 1 2  
status Sets or returns the text in the statusbar of the window
设置或获取位于窗口底部状态栏的信息。
3 1 2  
top Returns the topmost ancestor window
获取最顶层的祖先窗口。
3 1 2  

Window 对象方法

Method
方法
Description
描述
IE F N W3C
alert() Displays an alert box with a specified message and an OK button
显示包含由应用程序自定义消息的对话框。
3 1 2  
attachEvent("event",pointer)  将指定函数绑定到事件,以便每当该事件在对象上触发时都调用该函数。 5      
blur() Removes focus from the current window
使元素失去焦点并触发 onblur 事件。
4 1 3  
clearInterval(ID) Cancels a timeout that is set with the setInterval() method
取消由setInterval()建立的间隔事件
4 1 4  
clearTimeout(ID) Cancels a timeout that is set with the setTimeout() method
取消由setTimeout()方法建立的间隔事件
3 1 2  
close() Closes the current window
关闭当前浏览器窗口
3 1 2  
confirm() Displays a dialog box with a specified message and an OK and a Cancel button
显示一个确认对话框,其中包含一个可选的消息和确定取消按钮。
3 1 2  
createPopup() Creates a pop-up window
创建弹出窗口。
5      
execScript("code", "lang")

Executes a specified script. The arguments can take the following values:
以给定语言执行指定的脚本。

code Required. The code to be executed
必选。所要执行的代码
lang Required. JScript | VBScript | JavaScript
必选。选择代码所属语言类型

4      
focus() Sets focus on the current window
聚焦到当前的窗口
4 1 3  
moveBy(x,y) Moves the window a specified number of pixels in relation to its current co-ordinates
将窗口的位置移动指定 xy 偏移值。
4 1 4  
moveTo(x,y) Moves the window's left and top edge to the specified co-ordinates
将窗口左上角的屏幕位置移动到指定的 xy 位置。
4 1 4  
navigate("URL") Loads the specified URL into the window
在当前窗口中装入指定 URL。
3      
open() Opens a new browser window
打开新窗口并装入给定 URL 的文档。
3      
print() Prints the contents of the current window
打印与窗口关联的文档。
5 1 4  
prompt()

Displays a dialog box that prompts the user for input
显示一个提示对话框,其中带有一条消息和一个输入框。

3 1 2  
resizeBy() Resizes the window by the specified pixels
更改窗口的当前位置缩放指定的 x 和 y 偏移量。
4      
resizeTo() Resizes the window to the specified width and height
将窗口的大小更改为指定的宽度和高度值。
4 1.5    
scroll() Deprecated. Use scrollTo() instead
将窗口滚动到自左上角起指定的 x 和 y 偏移量。
4      
scrollBy() Scrolls the content by the specified number of pixels
将窗口滚动 x 和 y 偏移量。
4 1 4  
scrollTo() Scrolls the content to the specified coordinates
将窗口滚动到指定的 x 和 y 偏移量。
4 1 4  
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:
每经过指定毫秒值后计算一个表达式。

code Required. A pointer to a function or the code to be executed
必选。指定要执行哪段代码或是函数
millisec Required. The number of milliseconds
必选。毫秒数
lang Optional. JScript | VBScript | JavaScript
可选。代码语言类型

4 1 4  
setTimeout()

Calls a function or evaluates an expression after a specified number of milliseconds
经过指定毫秒值后计算一个表达式。

3 1 2  
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:
显示帮助文件。此方法可用于 Microsoft HTML 帮助。

URL Required. The URL of a Help file
必选。帮助文件的URL
contextID Optional. 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:
创建一个显示指定 HTML 文档的模式对话框。

"URL" - Required. The URL of the document to display.
'URL' - 必选的。所显示文档的URL

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.
参数 - 可选。什么时候显示URL.使用这个参数来传递任何类型的值,可以是数组值。对话框可以从window对象的dialogArguments属性中抽出值

"list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:
'list' - 可选。指定对话框窗口的修饰,用一种或多种下列的值,每个值用分号隔开。

dialogHeight : number the height* of the dialog window
对话窗口的高度
dialogLeft : number the left position of the dialog window
左定位
dialogTop : number the top position of the dialog window
上定位
dialogWidth : number the width* of the dialog window
窗口的宽度
center : yes | no | 1 | 0 | on | off whether to center the dialog window within the desktop. Default is yes
是否显示在桌面的中间位置
dialogHide : yes | no | 1 | 0 | on | off whether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
是否隐藏所输出的内容,只对于可信的程序所打开的对话框才会有效。默认为 no
edge : sunken | raised the edge style of the dialog window. Default is raised
对话框窗口的边缘样式
help : yes | no | 1 | 0 | on | off whether the dialog window displays the Help icon. Default is yes
是否显示帮助图标
resizable : yes | no | 1 | 0 | on | off whether the dialog window is resizable. Default is no
对话窗口的大小是否可做调整。默认为否
scroll : yes | no | 1 | 0 | on | off whether the dialog window displays scrollbars. Default is yes
是否显示滚动条,默认为是
status : yes | no | 1 | 0 | on | off whether 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 | off whether 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:
创建一个显示指定 HTML 文档的非模式对话框。

"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 : number the height* of the dialog window
dialogLeft : number the left position of the dialog window
dialogTop : number the top position of the dialog window
dialogWidth : number the width* of the dialog window
center : yes | no | 1 | 0 | on | off whether to center the dialog window within the desktop. Default is yes
dialogHide : yes | no | 1 | 0 | on | off whether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
edge : sunken | raised the edge style of the dialog window. Default is raised
help : yes | no | 1 | 0 | on | off whether the dialog window displays the Help icon. Default is yes
resizable : yes | no | 1 | 0 | on | off whether the dialog window is resizable. Default is no
scroll : yes | no | 1 | 0 | on | off whether the dialog window displays scrollbars. Default is yes
status : yes | no | 1 | 0 | on | off whether 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 | off whether 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.
在IE4中dialogHeight 和dialogWidth的默认单位是em。在IE5为px。其它的单位会混淆结果,最好用px! 注意:dialogHeight的最小值为100px

Window 对象事件

语法 window.event_name="someJavaScriptCode"

Event
事件
Description
描述
IE F N W3C
onBlur Executes some code when a Blur event occurs
对象失去输入焦点时触发。
  1 3  
onError Executes some code when an Error event occurs
对象装载过程中发生错误时触发。
  1 3  
onFocus Executes some code when a Focus event occurs
对象获得焦点时触发。
  1 3  
onLoad Executes some code when an Load event occurs
在浏览器完成对象的装载后立即触发。
  1 2  
onResize Executes some code when a Resize event occurs
对象的大小将要改变时触发。
  1 4  
onUnload Executes some code when an Unload event occurs
对象卸载前立即触发。
  1 2  

评论 (0) All

登陆 | 还没注册?