html dom 对象 window对象 document对象,HTML DOM Window 对象

HTML DOM Window 对象

Window 对象

Window 对象用于描述浏览器窗口. A Window object is created automatically with every instance of a

or tag.

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

Window 对象集合

集合

说明

IE

F

N

W3C

frames[]

返回所有在window中已经命名的frame

3

1

2

对象名

说明

IE

F

N

W3C

clientInformation

包含了有关浏览器的信息

4

clipboardData

包含了系统剪贴板的有关数据信息

5

这个对象可用于访问页面中的所有元素

3

event

描述某一事件状态

4

external

4

包含了用户曾经用浏览器访问过的URL

3

包含了当前浏览器地址栏中的URL

3

包含了客户端浏览器的相关信息

3

包含了客户端显示屏的相关信息

4

Window 对象属性

属性名

说明

IE

F

N

W3C

closed

返回所引用窗口是否关闭的boolean型值

4

1

3

defaultStatus

设置或返回浏览器窗口状态栏的缺省文本(在页面载入时显示)

3

1

2

dialogArguments

返回所有传递到模式对话框窗口中的参数

4

dialogHeight

设置或返回模式对话框窗口的高度

4

dialogLeft

设置或返回模式对话框窗口距屏幕左边界的距离(单位为像素)

4

dialogTop

设置或返回模式对话框窗口距屏幕顶部边界的距离(单位为像素)

4

dialogWidth

设置或返回模式对话框窗口的宽度

4

frameElement

返回 frame 或 iframe 对象所在父文档的窗口

5

length

设置或返回窗口中包含的frame的数量

4

1

6

name

设置或返回窗口的名称

3

1

2

offscreenBuffering

设置或获取对象在对用户可见之前是否要先在屏幕外绘制

4

opener

设置或获取创建当前窗口的窗口的引用

4

1

3

parent

获取对象层次中的父窗口

3

1

2

returnValue

设置或获取从模式对话框返回的值

4

screenLeft

获取浏览器客户端左上角相对于屏幕左上角的 x 坐标

5

screenTop

获取浏览器客户端左上角相对于屏幕左上角的 y 坐标

5

返回对当前窗口的引用

3

1

2

设置或获取位于窗口底部状态栏的信息

3

1

2

获取最顶层的祖先窗口

3

1

2

Window 对象方法

方法

说明

IE

F

N

W3C

显示一个带有指定信息和确定按钮的警告对话框

3

1

2

attachEvent("event",pointer)

5

blur()

将焦点从当前窗口移除

4

1

3

clearInterval(ID)

取消由setInterval() 方法设置的timeout时间

4

1

4

clearTimeout(ID)

取消由setTimeout()方法设置的timeout时间

3

1

2

close()

关闭当前窗口

3

1

2

显示一个带有指定信息和确定、取消按钮的对话框

3

1

2

execScript("code", "lang")

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

code

必需,要执行的脚本代码

lang

必需,为 JScript 、 VBScript 、 JavaScript一种

4

focus()

设这当前窗口的焦点位置

4

1

3

moveBy(x,y)

将当前窗口移动指定大小个像素位置(相对当前位置)

4

1

4

moveTo(x,y)

将当前窗口移动到指定位置(绝对位置)

4

1

4

navigate("URL")

载入指定的URL到当前窗口

3

打开一个新浏览窗口

3

打印当前窗口的内容

5

1

4

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

3

1

2

缩放当前窗口指定个像素大小(相对缩放)

4

缩放当前窗口到指定大小(绝对缩放)

4

1.5

scroll()

(不推荐使用). 使用 scrollTo() 来代替

4

滚动当前窗口内容指定个像素位置(相对滚动)

4

1

4

滚动当前窗口内容到指定像素位置(绝对滚动)

4

1

4

setActive()

5

setInterval(code, millisec[, "lang"])

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

code

(必须).一个函数或一段要执行的代码

millisec

(必须). 毫秒数

lang

(可选). JScript | VBScript | JavaScript

4

1

4

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

3

1

2

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 : 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

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 : 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.

Window Object Events

Syntax: 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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值