HTML DOM Window 对象

HTML DOM Window 对象


Window 对象

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 对象集合

集合说明IEFNW3C
frames[]返回所有在window中已经命名的frame312 

 

对象名说明IE FNW3C
clientInformation包含了有关浏览器的信息4   
clipboardData包含了系统剪贴板的有关数据信息5   
document这个对象可用于访问页面中的所有元素3   
event描述某一事件状态4   
external 4   
history包含了用户曾经用浏览器访问过的URL3   
location包含了当前浏览器地址栏中的URL3   
navigator包含了客户端浏览器的相关信息3   
screen包含了客户端显示屏的相关信息4   

Window 对象属性

属性名说明IE FNW3C
closed返回所引用窗口是否关闭的boolean型值413 
defaultStatus设置或返回浏览器窗口状态栏的缺省文本(在页面载入时显示)312 
dialogArguments返回所有传递到模式对话框窗口中的参数4   
dialogHeight设置或返回模式对话框窗口的高度4   
dialogLeft设置或返回模式对话框窗口距屏幕左边界的距离(单位为像素)4   
dialogTop设置或返回模式对话框窗口距屏幕顶部边界的距离(单位为像素)4   
dialogWidth设置或返回模式对话框窗口的宽度4   
frameElement返回 frame 或 iframe 对象所在父文档的窗口5   
length设置或返回窗口中包含的frame的数量416 
name设置或返回窗口的名称312 
offscreenBuffering设置或获取对象在对用户可见之前是否要先在屏幕外绘制4   
opener设置或获取创建当前窗口的窗口的引用413 
parent获取对象层次中的父窗口312 
returnValue设置或获取从模式对话框返回的值4   
screenLeft获取浏览器客户端左上角相对于屏幕左上角的 x 坐标5   
screenTop获取浏览器客户端左上角相对于屏幕左上角的 y 坐标5   
self返回对当前窗口的引用312 
status设置或获取位于窗口底部状态栏的信息312 
top获取最顶层的祖先窗口312 

Window 对象方法

方法说明IEFNW3C
alert()显示一个带有指定信息和确定按钮的警告对话框312 
attachEvent("event",pointer) 5   
blur()将焦点从当前窗口移除413 
clearInterval(ID) 取消由setInterval() 方法设置的timeout时间414 
clearTimeout(ID) 取消由setTimeout()方法设置的timeout时间312 
close()关闭当前窗口312 
confirm()显示一个带有指定信息和确定、取消按钮的对话框312 
createPopup()创建弹出窗口5   
execScript("code", "lang")

执行指定的脚本, 参数说明如下:

code必需,要执行的脚本代码
lang必需,为 JScript 、 VBScript 、 JavaScript一种

4   
focus()设这当前窗口的焦点位置413 
moveBy(x,y)将当前窗口移动指定大小个像素位置(相对当前位置)414 
moveTo(x,y)将当前窗口移动到指定位置(绝对位置)414 
navigate("URL")载入指定的URL到当前窗口3   
open()打开一个新浏览窗口3   
print()打印当前窗口的内容514 
prompt()

显示一个提示用户输入的对话框

312 
resizeBy()缩放当前窗口指定个像素大小(相对缩放)4   
resizeTo()缩放当前窗口到指定大小(绝对缩放)41.5  
scroll()(不推荐使用). 使用 scrollTo() 来代替4   
scrollBy()滚动当前窗口内容指定个像素位置(相对滚动)414 
scrollTo()滚动当前窗口内容到指定像素位置(绝对滚动)414 
setActive() 5   
setInterval(code, millisec[, "lang"])

在指定时间间隔内执行指定的代码,参数含义如下:

code(必须).一个函数或一段要执行的代码
millisec(必须). 毫秒数
lang(可选). JScript | VBScript | JavaScript

414 
setTimeout()

在指定时间后调用一个函数或一段代码

312 
showHelp("URL"[, contextID])

显示一个帮助文件 (必须是.htm或.chm格式). 使用此方法时,当用户点击F1或点击菜单栏上的帮助时会弹出一个帮助窗口, 为防止出现默认的帮助窗口应该设置返回值为false, 参数含义如下

URL(必须). 帮助文件的URL
contextID(可选). 一个指向帮助文件指定章节的标识,可以为string 或integer型

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 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值