Window interface

包含 DOM 文档的窗口;文档属性指向在该窗口中加载的 DOM 文档。

扩展

EventTarget,AnimationFrameProvider,GlobalEventHandlers,WindowEventHandlers,WindowLocalStorage,WindowOrWorkerGlobalScope,WindowSessionStorage

属性

clientInformation
closed

如果窗口已关闭,则返回 true,否则返回 false。

customElements

定义新的自定义元素,将给定名称映射到给定构造函数作为自治自定义元素。

devicePixelRatio
document
event
external
frameElement
frames
history
innerHeight
innerWidth
length
___location
locationbar

如果位置栏可见,则返回 true;否则返回 false。

menubar

如果菜单栏可见,则返回 true;否则返回 false。

msCrypto
name
navigator
ondevicemotion

仅在安全上下文中可用。

ondeviceorientation

仅在安全上下文中可用。

onorientationchange
opener
orientation
outerHeight
outerWidth
pageXOffset
pageYOffset
parent

指父 WindowProxy 或本身。

它很少为 null,例如,对于已从父级中删除的 iframe 的 contentWindow。

personalbar

如果个人栏可见,则返回 true;否则返回 false。

powerbi
powerBISDKGlobalServiceInstanceName
screen
screenLeft
screenTop
screenX
screenY
scrollbars

如果滚动条可见,则返回 true;否则返回 false。

scrollX
scrollY
self
speechSynthesis
status
statusbar

如果状态栏可见,则返回 true;否则返回 false。

toolbar

如果工具栏可见,则返回 true;否则返回 false。

top
visualViewport
window

继承属性

caches

仅在安全上下文中可用。

crossOriginIsolated
crypto
indexedDB
isSecureContext
localStorage
onabort

当用户中止下载时触发。

onafterprint
onanimationcancel
onanimationend
onanimationiteration
onanimationstart
onauxclick
onbeforeinput
onbeforeprint
onbeforeunload
onblur

当对象失去输入焦点时触发。

oncancel
oncanplay

在可能播放时发生,但需要进一步缓冲。

oncanplaythrough
onchange

当对象或所选内容发生更改时触发。

onclick

当用户单击对象上的鼠标左键时触发

onclose
oncontextmenu

当用户在工作区中单击鼠标右键时触发,打开上下文菜单。

oncuechange
ondblclick

当用户双击对象时触发。

ondrag

在拖动操作期间持续触发源对象。

ondragend

当用户在拖动操作关闭时释放鼠标时,会触发源对象。

ondragenter

当用户将对象拖动到有效的放置目标时,将触发目标元素。

ondragleave

当用户在拖动操作期间将鼠标移出有效放置目标时,会触发目标对象。

ondragover

当用户将对象拖动到有效的放置目标上时,会持续触发目标元素。

ondragstart

当用户开始拖动文本选择或所选对象时,将触发源对象。

ondrop
ondurationchange

在更新持续时间属性时发生。

onemptied

当媒体元素重置为其初始状态时发生。

onended

到达播放结束时发生。

onerror

在对象加载期间发生错误时触发。

onfocus

当对象收到焦点时触发。

onformdata
ongamepadconnected
ongamepaddisconnected
ongotpointercapture
onhashchange
oninput
oninvalid
onkeydown

当用户按下键时触发。

onkeypress

当用户按下字母数字键时触发。

onkeyup

当用户释放密钥时触发。

onlanguagechange
onload

在浏览器加载对象后立即触发。

onloadeddata

在当前播放位置加载媒体数据时发生。

onloadedmetadata

在确定媒体的持续时间和维度时发生。

onloadstart

当 Internet Explorer 开始查找媒体数据时发生。

onlostpointercapture
onmessage
onmessageerror
onmousedown

当用户使用任一鼠标按钮单击对象时触发。

onmouseenter
onmouseleave
onmousemove

当用户将鼠标移到对象上时触发。

onmouseout

当用户将鼠标指针移到对象的边界之外时触发。

onmouseover

当用户将鼠标指针移到对象中时触发。

onmouseup

当用户在鼠标悬停在对象上时释放鼠标按钮时触发。

onoffline
ononline
onpagehide
onpageshow
onpause

暂停播放时发生。

onplay

请求 play 方法时发生。

onplaying

当音频或视频开始播放时发生。

onpointercancel
onpointerdown
onpointerenter
onpointerleave
onpointermove
onpointerout
onpointerover
onpointerup
onpopstate
onprogress

在下载媒体数据时发生指示进度。

onratechange

当播放速率增加或减少时发生。

onrejectionhandled
onreset

当用户重置窗体时触发。

onresize
onscroll

当用户在对象的滚动条中重新定位滚动框时触发。

onsecuritypolicyviolation
onseeked

在搜寻操作结束时发生。

onseeking

移动当前播放位置时发生。

onselect

当当前所选内容更改时触发。

onselectionchange
onselectstart
onslotchange
onstalled

下载停止时发生。

onstorage
onsubmit
onsuspend

如果加载操作已有意停止,则发生此情况。

ontimeupdate

发生以指示当前播放位置。

ontoggle
ontouchcancel
ontouchend
ontouchmove
ontouchstart
ontransitioncancel
ontransitionend
ontransitionrun
ontransitionstart
onunhandledrejection
onunload
onvolumechange

更改音量或播放静音或取消静音时发生。

onwaiting

播放停止时发生,因为视频资源的下一帧不可用。

onwebkitanimationend
onwebkitanimationiteration
onwebkitanimationstart
onwebkittransitionend
onwheel
origin
performance
sessionStorage

方法

addEventListener(string, EventListenerOrEventListenerObject, boolean | AddEventListenerOptions)
addEventListener<K>(K, (this: Window, ev: WindowEventMap[K]) => any, boolean | AddEventListenerOptions)
alert(any)
blur()
cancelIdleCallback(number)
captureEvents()
close()

关闭窗口。

confirm(string)
focus()

将焦点移动到窗口的浏览上下文(如果有)。

getComputedStyle(Element, null | string)
getSelection()
matchMedia(string)
moveBy(number, number)
moveTo(number, number)
open(string | URL, string, string)
postMessage(any, string, Transferable[])

将消息发布到给定窗口。 消息可以是结构化对象,例如嵌套对象和数组,可以包含 JavaScript 值(字符串、数字、日期对象等),并且可以包含某些数据对象,如文件 Blob、FileList 和 ArrayBuffer 对象。

选项传输成员中列出的对象将传输,而不仅仅是克隆,这意味着它们不再可用于发送端。

可以使用选项的 targetOrigin 成员指定目标源。 如果未提供,则默认为“/”。 此默认值仅将消息限制为同源目标。

如果目标窗口的源与给定的目标源不匹配,则会丢弃该消息,以避免信息泄露。 若要将消息发送到目标而不考虑来源,请将目标源设置为“*”。

如果传输数组包含重复的对象或无法克隆消息,则引发“DataCloneError”DOMException。

postMessage(any, WindowPostMessageOptions)
print()
prompt(string, string)
releaseEvents()
removeEventListener(string, EventListenerOrEventListenerObject, boolean | EventListenerOptions)
removeEventListener<K>(K, (this: Window, ev: WindowEventMap[K]) => any, boolean | EventListenerOptions)
requestIdleCallback(IdleRequestCallback, IdleRequestOptions)
resizeBy(number, number)
resizeTo(number, number)
scroll(number, number)
scroll(ScrollToOptions)
scrollBy(number, number)
scrollBy(ScrollToOptions)
scrollTo(number, number)
scrollTo(ScrollToOptions)
stop()

取消文档加载。

继承的方法

atob(string)
btoa(string)
cancelAnimationFrame(number)
clearInterval(undefined | number)
clearTimeout(undefined | number)
createImageBitmap(ImageBitmapSource, ImageBitmapOptions)
createImageBitmap(ImageBitmapSource, number, number, number, number, ImageBitmapOptions)
dispatchEvent(Event)

如果事件的可取消属性值为 false 或其 preventDefault() 方法未调用,则调度合成事件事件的目标并返回 true;否则返回 false。

fetch(URL | RequestInfo, RequestInit)
queueMicrotask(VoidFunction)
reportError(any)
requestAnimationFrame(FrameRequestCallback)
setInterval(TimerHandler, number, any[])
setTimeout(TimerHandler, number, any[])
structuredClone(any, StructuredSerializeOptions)

属性详细信息

clientInformation

警告

现已弃用此 API。

This is a legacy alias of navigator.

clientInformation: Navigator

属性值

Navigator

closed

如果窗口已关闭,则返回 true,否则返回 false。

closed: boolean

属性值

boolean

customElements

定义新的自定义元素,将给定名称映射到给定构造函数作为自治自定义元素。

customElements: CustomElementRegistry

属性值

CustomElementRegistry

devicePixelRatio

devicePixelRatio: number

属性值

number

document

document: Document

属性值

Document

event

警告

现已弃用此 API。

event: undefined | Event

属性值

undefined | Event

external

警告

现已弃用此 API。

external: External

属性值

External

frameElement

frameElement: null | Element

属性值

null | Element

frames

frames: Window

属性值

Window

history

history: History

属性值

History

innerHeight

innerHeight: number

属性值

number

innerWidth

innerWidth: number

属性值

number

length

length: number

属性值

number

___location

Location ___location

属性值

Location

locationbar

如果位置栏可见,则返回 true;否则返回 false。

locationbar: BarProp

属性值

BarProp

menubar

如果菜单栏可见,则返回 true;否则返回 false。

menubar: BarProp

属性值

BarProp

msCrypto

msCrypto: Crypto

属性值

Crypto

name

name: string

属性值

string

navigator

navigator: Navigator

属性值

Navigator

ondevicemotion

仅在安全上下文中可用。

ondevicemotion: null | (this: Window, ev: DeviceMotionEvent) => any

属性值

null | (this: Window, ev: DeviceMotionEvent) => any

ondeviceorientation

仅在安全上下文中可用。

ondeviceorientation: null | (this: Window, ev: DeviceOrientationEvent) => any

属性值

null | (this: Window, ev: DeviceOrientationEvent) => any

onorientationchange

警告

现已弃用此 API。

onorientationchange: null | (this: Window, ev: Event) => any

属性值

null | (this: Window, ev: Event) => any

opener

opener: any

属性值

any

orientation

警告

现已弃用此 API。

orientation: number

属性值

number

outerHeight

outerHeight: number

属性值

number

outerWidth

outerWidth: number

属性值

number

pageXOffset

警告

现已弃用此 API。

This is a legacy alias of scrollX.

pageXOffset: number

属性值

number

pageYOffset

警告

现已弃用此 API。

This is a legacy alias of scrollY.

pageYOffset: number

属性值

number

parent

指父 WindowProxy 或本身。

它很少为 null,例如,对于已从父级中删除的 iframe 的 contentWindow。

parent: Window

属性值

Window

personalbar

如果个人栏可见,则返回 true;否则返回 false。

personalbar: BarProp

属性值

BarProp

powerbi

powerbi: Service

属性值

powerBISDKGlobalServiceInstanceName

powerBISDKGlobalServiceInstanceName?: string

属性值

string

screen

screen: Screen

属性值

Screen

screenLeft

screenLeft: number

属性值

number

screenTop

screenTop: number

属性值

number

screenX

screenX: number

属性值

number

screenY

screenY: number

属性值

number

scrollbars

如果滚动条可见,则返回 true;否则返回 false。

scrollbars: BarProp

属性值

BarProp

scrollX

scrollX: number

属性值

number

scrollY

scrollY: number

属性值

number

self

self: Window & typeof globalThis

属性值

Window & typeof globalThis

speechSynthesis

speechSynthesis: SpeechSynthesis

属性值

SpeechSynthesis

status

警告

现已弃用此 API。

status: string

属性值

string

statusbar

如果状态栏可见,则返回 true;否则返回 false。

statusbar: BarProp

属性值

BarProp

toolbar

如果工具栏可见,则返回 true;否则返回 false。

toolbar: BarProp

属性值

BarProp

top

top: null | Window

属性值

null | Window

visualViewport

visualViewport: null | VisualViewport

属性值

null | VisualViewport

window

window: Window & typeof globalThis

属性值

Window & typeof globalThis

继承属性详细信息

caches

仅在安全上下文中可用。

caches: CacheStorage

属性值

CacheStorage

继承自 WindowOrWorkerGlobalScope.caches

crossOriginIsolated

crossOriginIsolated: boolean

属性值

boolean

继承自 WindowOrWorkerGlobalScope.crossOriginIsolated

crypto

crypto: Crypto

属性值

Crypto

继承自 WindowOrWorkerGlobalScope.crypto

indexedDB

indexedDB: IDBFactory

属性值

IDBFactory

继承自 WindowOrWorkerGlobalScope.indexedDB

isSecureContext

isSecureContext: boolean

属性值

boolean

继承自 WindowOrWorkerGlobalScope.isSecureContext

localStorage

localStorage: Storage

属性值

Storage

继承自 WindowLocalStorage.localStorage

onabort

当用户中止下载时触发。

onabort: null | (this: GlobalEventHandlers, ev: UIEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: UIEvent) => any

继承自 GlobalEventHandlers.onabort

onafterprint

onafterprint: null | (this: WindowEventHandlers, ev: Event) => any

属性值

null | (this: WindowEventHandlers, ev: Event) => any

继承自 WindowEventHandlers.onafterprint

onanimationcancel

onanimationcancel: null | (this: GlobalEventHandlers, ev: AnimationEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: AnimationEvent) => any

继承自 GlobalEventHandlers.onanimationcancel

onanimationend

onanimationend: null | (this: GlobalEventHandlers, ev: AnimationEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: AnimationEvent) => any

继承自 GlobalEventHandlers.onanimationend

onanimationiteration

onanimationiteration: null | (this: GlobalEventHandlers, ev: AnimationEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: AnimationEvent) => any

继承自 GlobalEventHandlers.onanimationiteration

onanimationstart

onanimationstart: null | (this: GlobalEventHandlers, ev: AnimationEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: AnimationEvent) => any

继承自 GlobalEventHandlers.onanimationstart

onauxclick

onauxclick: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.onauxclick

onbeforeinput

onbeforeinput: null | (this: GlobalEventHandlers, ev: InputEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: InputEvent) => any

继承自 GlobalEventHandlers.onbeforeinput

onbeforeprint

onbeforeprint: null | (this: WindowEventHandlers, ev: Event) => any

属性值

null | (this: WindowEventHandlers, ev: Event) => any

继承自 WindowEventHandlers.onbeforeprint

onbeforeunload

onbeforeunload: null | (this: WindowEventHandlers, ev: BeforeUnloadEvent) => any

属性值

null | (this: WindowEventHandlers, ev: BeforeUnloadEvent) => any

继承自 WindowEventHandlers.onbeforeunload

onblur

当对象失去输入焦点时触发。

onblur: null | (this: GlobalEventHandlers, ev: FocusEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: FocusEvent) => any

继承自 GlobalEventHandlers.onblur

oncancel

oncancel: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 globalEventHandlers.oncancel 的

oncanplay

在可能播放时发生,但需要进一步缓冲。

oncanplay: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.oncanplay

oncanplaythrough

oncanplaythrough: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.oncanplaythrough

onchange

当对象或所选内容发生更改时触发。

onchange: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onchange

onclick

当用户单击对象上的鼠标左键时触发

onclick: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.onclick

onclose

onclose: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onclose

oncontextmenu

当用户在工作区中单击鼠标右键时触发,打开上下文菜单。

oncontextmenu: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.oncontextmenu

oncuechange

oncuechange: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.oncuechange

ondblclick

当用户双击对象时触发。

ondblclick: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.ondblclick

ondrag

在拖动操作期间持续触发源对象。

ondrag: null | (this: GlobalEventHandlers, ev: DragEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: DragEvent) => any

继承自 GlobalEventHandlers.ondrag

ondragend

当用户在拖动操作关闭时释放鼠标时,会触发源对象。

ondragend: null | (this: GlobalEventHandlers, ev: DragEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: DragEvent) => any

继承自 GlobalEventHandlers.ondragend

ondragenter

当用户将对象拖动到有效的放置目标时,将触发目标元素。

ondragenter: null | (this: GlobalEventHandlers, ev: DragEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: DragEvent) => any

继承自 GlobalEventHandlers.ondragenter

ondragleave

当用户在拖动操作期间将鼠标移出有效放置目标时,会触发目标对象。

ondragleave: null | (this: GlobalEventHandlers, ev: DragEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: DragEvent) => any

继承自 GlobalEventHandlers.ondragleave

ondragover

当用户将对象拖动到有效的放置目标上时,会持续触发目标元素。

ondragover: null | (this: GlobalEventHandlers, ev: DragEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: DragEvent) => any

继承自 GlobalEventHandlers.ondragover

ondragstart

当用户开始拖动文本选择或所选对象时,将触发源对象。

ondragstart: null | (this: GlobalEventHandlers, ev: DragEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: DragEvent) => any

继承自 GlobalEventHandlers.ondragstart

ondrop

ondrop: null | (this: GlobalEventHandlers, ev: DragEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: DragEvent) => any

继承自 GlobalEventHandlers.ondrop

ondurationchange

在更新持续时间属性时发生。

ondurationchange: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.ondurationchange

onemptied

当媒体元素重置为其初始状态时发生。

onemptied: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onemptied

onended

到达播放结束时发生。

onended: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onended

onerror

在对象加载期间发生错误时触发。

onerror: OnErrorEventHandler

属性值

OnErrorEventHandler

继承自 GlobalEventHandlers.onerror

onfocus

当对象收到焦点时触发。

onfocus: null | (this: GlobalEventHandlers, ev: FocusEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: FocusEvent) => any

继承自 GlobalEventHandlers.onfocus

onformdata

onformdata: null | (this: GlobalEventHandlers, ev: FormDataEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: FormDataEvent) => any

继承自 GlobalEventHandlers.onformdata

ongamepadconnected

ongamepadconnected: null | (this: WindowEventHandlers, ev: GamepadEvent) => any

属性值

null | (this: WindowEventHandlers, ev: GamepadEvent) => any

继承自 WindowEventHandlers.ongamepadconnected

ongamepaddisconnected

ongamepaddisconnected: null | (this: WindowEventHandlers, ev: GamepadEvent) => any

属性值

null | (this: WindowEventHandlers, ev: GamepadEvent) => any

继承自 WindowEventHandlers.ongamepaddisconnected

ongotpointercapture

ongotpointercapture: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.ongotpointercapture

onhashchange

onhashchange: null | (this: WindowEventHandlers, ev: HashChangeEvent) => any

属性值

null | (this: WindowEventHandlers, ev: HashChangeEvent) => any

继承自 WindowEventHandlers.onhashchange

oninput

oninput: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.oninput

oninvalid

oninvalid: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.oninvalid

onkeydown

当用户按下键时触发。

onkeydown: null | (this: GlobalEventHandlers, ev: KeyboardEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: KeyboardEvent) => any

继承自 GlobalEventHandlers.onkeydown

onkeypress

警告

现已弃用此 API。

当用户按下字母数字键时触发。

onkeypress: null | (this: GlobalEventHandlers, ev: KeyboardEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: KeyboardEvent) => any

继承自 GlobalEventHandlers.onkeypress 的

onkeyup

当用户释放密钥时触发。

onkeyup: null | (this: GlobalEventHandlers, ev: KeyboardEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: KeyboardEvent) => any

继承自 GlobalEventHandlers.onkeyup

onlanguagechange

onlanguagechange: null | (this: WindowEventHandlers, ev: Event) => any

属性值

null | (this: WindowEventHandlers, ev: Event) => any

继承自 WindowEventHandlers.onlanguagechange

onload

在浏览器加载对象后立即触发。

onload: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onload

onloadeddata

在当前播放位置加载媒体数据时发生。

onloadeddata: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onloadeddata

onloadedmetadata

在确定媒体的持续时间和维度时发生。

onloadedmetadata: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onloadedmetadata

onloadstart

当 Internet Explorer 开始查找媒体数据时发生。

onloadstart: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onloadstart

onlostpointercapture

onlostpointercapture: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.onlostpointercapture

onmessage

onmessage: null | (this: WindowEventHandlers, ev: MessageEvent<any>) => any

属性值

null | (this: WindowEventHandlers, ev: MessageEvent<any>) => any

继承自 WindowEventHandlers.onmessage

onmessageerror

onmessageerror: null | (this: WindowEventHandlers, ev: MessageEvent<any>) => any

属性值

null | (this: WindowEventHandlers, ev: MessageEvent<any>) => any

继承自 WindowEventHandlers.onmessageerror

onmousedown

当用户使用任一鼠标按钮单击对象时触发。

onmousedown: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.onmousedown

onmouseenter

onmouseenter: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.onmouseenter

onmouseleave

onmouseleave: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.onmouseleave

onmousemove

当用户将鼠标移到对象上时触发。

onmousemove: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.onmousemove

onmouseout

当用户将鼠标指针移到对象的边界之外时触发。

onmouseout: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.onmouseout

onmouseover

当用户将鼠标指针移到对象中时触发。

onmouseover: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.onmouseover

onmouseup

当用户在鼠标悬停在对象上时释放鼠标按钮时触发。

onmouseup: null | (this: GlobalEventHandlers, ev: MouseEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: MouseEvent) => any

继承自 GlobalEventHandlers.onmouseup

onoffline

onoffline: null | (this: WindowEventHandlers, ev: Event) => any

属性值

null | (this: WindowEventHandlers, ev: Event) => any

继承自 WindowEventHandlers.onoffline

ononline

ononline: null | (this: WindowEventHandlers, ev: Event) => any

属性值

null | (this: WindowEventHandlers, ev: Event) => any

继承自 WindowEventHandlers.ononline

onpagehide

onpagehide: null | (this: WindowEventHandlers, ev: PageTransitionEvent) => any

属性值

null | (this: WindowEventHandlers, ev: PageTransitionEvent) => any

继承自 WindowEventHandlers.onpagehide

onpageshow

onpageshow: null | (this: WindowEventHandlers, ev: PageTransitionEvent) => any

属性值

null | (this: WindowEventHandlers, ev: PageTransitionEvent) => any

继承自 WindowEventHandlers.onpageshow

onpause

暂停播放时发生。

onpause: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onpause

onplay

请求 play 方法时发生。

onplay: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onplay

onplaying

当音频或视频开始播放时发生。

onplaying: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onplaying

onpointercancel

onpointercancel: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.onpointercancel

onpointerdown

onpointerdown: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.onpointerdown

onpointerenter

onpointerenter: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.onpointerenter

onpointerleave

onpointerleave: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.onpointerleave

onpointermove

onpointermove: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.onpointermove

onpointerout

onpointerout: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.onpointerout

onpointerover

onpointerover: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.onpointerover

onpointerup

onpointerup: null | (this: GlobalEventHandlers, ev: PointerEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: PointerEvent) => any

继承自 GlobalEventHandlers.onpointerup

onpopstate

onpopstate: null | (this: WindowEventHandlers, ev: PopStateEvent) => any

属性值

null | (this: WindowEventHandlers, ev: PopStateEvent) => any

继承自 WindowEventHandlers.onpopstate

onprogress

在下载媒体数据时发生指示进度。

onprogress: null | (this: GlobalEventHandlers, ev: ProgressEvent<EventTarget>) => any

属性值

null | (this: GlobalEventHandlers, ev: ProgressEvent<EventTarget>) => any

继承自 GlobalEventHandlers.onprogress

onratechange

当播放速率增加或减少时发生。

onratechange: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onratechange

onrejectionhandled

onrejectionhandled: null | (this: WindowEventHandlers, ev: PromiseRejectionEvent) => any

属性值

null | (this: WindowEventHandlers, ev: PromiseRejectionEvent) => any

继承自 WindowEventHandlers.onrejectionhandled

onreset

当用户重置窗体时触发。

onreset: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onreset

onresize

onresize: null | (this: GlobalEventHandlers, ev: UIEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: UIEvent) => any

继承自 GlobalEventHandlers.onresize

onscroll

当用户在对象的滚动条中重新定位滚动框时触发。

onscroll: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onscroll

onsecuritypolicyviolation

onsecuritypolicyviolation: null | (this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: SecurityPolicyViolationEvent) => any

继承自 GlobalEventHandlers.onsecuritypolicyviolation

onseeked

在搜寻操作结束时发生。

onseeked: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onseeked

onseeking

移动当前播放位置时发生。

onseeking: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onseeking

onselect

当当前所选内容更改时触发。

onselect: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onselect

onselectionchange

onselectionchange: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onselectionchange

onselectstart

onselectstart: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onselectstart

onslotchange

onslotchange: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onslotchange

onstalled

下载停止时发生。

onstalled: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onstalled

onstorage

onstorage: null | (this: WindowEventHandlers, ev: StorageEvent) => any

属性值

null | (this: WindowEventHandlers, ev: StorageEvent) => any

继承自 WindowEventHandlers.onstorage

onsubmit

onsubmit: null | (this: GlobalEventHandlers, ev: SubmitEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: SubmitEvent) => any

继承自 GlobalEventHandlers.onsubmit

onsuspend

如果加载操作已有意停止,则发生此情况。

onsuspend: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onsuspend

ontimeupdate

发生以指示当前播放位置。

ontimeupdate: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.ontimeupdate

ontoggle

ontoggle: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onggle

ontouchcancel

ontouchcancel?: null | (this: GlobalEventHandlers, ev: TouchEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: TouchEvent) => any

继承自 GlobalEventHandlers.ontouchcancel

ontouchend

ontouchend?: null | (this: GlobalEventHandlers, ev: TouchEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: TouchEvent) => any

继承自 GlobalEventHandlers.ontouchend

ontouchmove

ontouchmove?: null | (this: GlobalEventHandlers, ev: TouchEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: TouchEvent) => any

继承自 GlobalEventHandlers.ontouchmove

ontouchstart

ontouchstart?: null | (this: GlobalEventHandlers, ev: TouchEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: TouchEvent) => any

继承自 GlobalEventHandlers.ontouchstart

ontransitioncancel

ontransitioncancel: null | (this: GlobalEventHandlers, ev: TransitionEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: TransitionEvent) => any

继承自 GlobalEventHandlers.ontransitioncancel

ontransitionend

ontransitionend: null | (this: GlobalEventHandlers, ev: TransitionEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: TransitionEvent) => any

继承自 GlobalEventHandlers.ontransitionend

ontransitionrun

ontransitionrun: null | (this: GlobalEventHandlers, ev: TransitionEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: TransitionEvent) => any

继承自 GlobalEventHandlers.ontransitionrun

ontransitionstart

ontransitionstart: null | (this: GlobalEventHandlers, ev: TransitionEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: TransitionEvent) => any

继承自 GlobalEventHandlers.ontransitionstart

onunhandledrejection

onunhandledrejection: null | (this: WindowEventHandlers, ev: PromiseRejectionEvent) => any

属性值

null | (this: WindowEventHandlers, ev: PromiseRejectionEvent) => any

继承自 WindowEventHandlers.onunhandledrejection

onunload

onunload: null | (this: WindowEventHandlers, ev: Event) => any

属性值

null | (this: WindowEventHandlers, ev: Event) => any

继承自 WindowEventHandlers.onunload

onvolumechange

更改音量或播放静音或取消静音时发生。

onvolumechange: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onvolumechange

onwaiting

播放停止时发生,因为视频资源的下一帧不可用。

onwaiting: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onwaiting

onwebkitanimationend

警告

现已弃用此 API。

This is a legacy alias of onanimationend.

onwebkitanimationend: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onwebkitanimationend

onwebkitanimationiteration

警告

现已弃用此 API。

This is a legacy alias of onanimationiteration.

onwebkitanimationiteration: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onwebkitanimationiteration

onwebkitanimationstart

警告

现已弃用此 API。

This is a legacy alias of onanimationstart.

onwebkitanimationstart: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onwebkitanimationstart

onwebkittransitionend

警告

现已弃用此 API。

This is a legacy alias of ontransitionend.

onwebkittransitionend: null | (this: GlobalEventHandlers, ev: Event) => any

属性值

null | (this: GlobalEventHandlers, ev: Event) => any

继承自 GlobalEventHandlers.onwebkittransitionend

onwheel

onwheel: null | (this: GlobalEventHandlers, ev: WheelEvent) => any

属性值

null | (this: GlobalEventHandlers, ev: WheelEvent) => any

继承自 GlobalEventHandlers.onwheel

origin

origin: string

属性值

string

继承自 WindowOrWorkerGlobalScope.origin

performance

performance: Performance

属性值

Performance

继承自 WindowOrWorkerGlobalScope.performance

sessionStorage

sessionStorage: Storage

属性值

Storage

继承自 WindowSessionStorage.sessionStorage

方法详细信息

addEventListener(string, EventListenerOrEventListenerObject, boolean | AddEventListenerOptions)

function addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions)

参数

type

string

listener

EventListenerOrEventListenerObject

options

boolean | AddEventListenerOptions

addEventListener<K>(K, (this: Window, ev: WindowEventMap[K]) => any, boolean | AddEventListenerOptions)

function addEventListener<K>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions)

参数

type

K

listener

(this: Window, ev: WindowEventMap[K]) => any

options

boolean | AddEventListenerOptions

alert(any)

function alert(message?: any)

参数

message

any

blur()

function blur()

cancelIdleCallback(number)

function cancelIdleCallback(handle: number)

参数

handle

number

captureEvents()

警告

现已弃用此 API。

function captureEvents()

close()

关闭窗口。

function close()

confirm(string)

function confirm(message?: string): boolean

参数

message

string

返回

boolean

focus()

将焦点移动到窗口的浏览上下文(如果有)。

function focus()

getComputedStyle(Element, null | string)

function getComputedStyle(elt: Element, pseudoElt?: null | string): CSSStyleDeclaration

参数

elt

Element

pseudoElt

null | string

返回

CSSStyleDeclaration

getSelection()

function getSelection(): null | Selection

返回

null | Selection

matchMedia(string)

function matchMedia(query: string): MediaQueryList

参数

query

string

返回

MediaQueryList

moveBy(number, number)

function moveBy(x: number, y: number)

参数

x

number

y

number

moveTo(number, number)

function moveTo(x: number, y: number)

参数

x

number

y

number

open(string | URL, string, string)

function open(url?: string | URL, target?: string, features?: string): null | Window

参数

url

string | URL

target

string

features

string

返回

null | Window

postMessage(any, string, Transferable[])

将消息发布到给定窗口。 消息可以是结构化对象,例如嵌套对象和数组,可以包含 JavaScript 值(字符串、数字、日期对象等),并且可以包含某些数据对象,如文件 Blob、FileList 和 ArrayBuffer 对象。

选项传输成员中列出的对象将传输,而不仅仅是克隆,这意味着它们不再可用于发送端。

可以使用选项的 targetOrigin 成员指定目标源。 如果未提供,则默认为“/”。 此默认值仅将消息限制为同源目标。

如果目标窗口的源与给定的目标源不匹配,则会丢弃该消息,以避免信息泄露。 若要将消息发送到目标而不考虑来源,请将目标源设置为“*”。

如果传输数组包含重复的对象或无法克隆消息,则引发“DataCloneError”DOMException。

function postMessage(message: any, targetOrigin: string, transfer?: Transferable[])

参数

message

any

targetOrigin

string

transfer

Transferable[]

postMessage(any, WindowPostMessageOptions)

function postMessage(message: any, options?: WindowPostMessageOptions)

参数

message

any

options

WindowPostMessageOptions

print()

function print()

prompt(string, string)

function prompt(message?: string, _default?: string): null | string

参数

message

string

_default

string

返回

null | string

releaseEvents()

警告

现已弃用此 API。

function releaseEvents()

removeEventListener(string, EventListenerOrEventListenerObject, boolean | EventListenerOptions)

function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions)

参数

type

string

listener

EventListenerOrEventListenerObject

options

boolean | EventListenerOptions

removeEventListener<K>(K, (this: Window, ev: WindowEventMap[K]) => any, boolean | EventListenerOptions)

function removeEventListener<K>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | EventListenerOptions)

参数

type

K

listener

(this: Window, ev: WindowEventMap[K]) => any

options

boolean | EventListenerOptions

requestIdleCallback(IdleRequestCallback, IdleRequestOptions)

function requestIdleCallback(callback: IdleRequestCallback, options?: IdleRequestOptions): number

参数

callback

IdleRequestCallback

options

IdleRequestOptions

返回

number

resizeBy(number, number)

function resizeBy(x: number, y: number)

参数

x

number

y

number

resizeTo(number, number)

function resizeTo(width: number, height: number)

参数

width

number

height

number

scroll(number, number)

function scroll(x: number, y: number)

参数

x

number

y

number

scroll(ScrollToOptions)

function scroll(options?: ScrollToOptions)

参数

options

ScrollToOptions

scrollBy(number, number)

function scrollBy(x: number, y: number)

参数

x

number

y

number

scrollBy(ScrollToOptions)

function scrollBy(options?: ScrollToOptions)

参数

options

ScrollToOptions

scrollTo(number, number)

function scrollTo(x: number, y: number)

参数

x

number

y

number

scrollTo(ScrollToOptions)

function scrollTo(options?: ScrollToOptions)

参数

options

ScrollToOptions

stop()

取消文档加载。

function stop()

继承的方法详细信息

atob(string)

function atob(data: string): string

参数

data

string

返回

string

继承自 WindowOrWorkerGlobalScope.atob

btoa(string)

function btoa(data: string): string

参数

data

string

返回

string

继承自 WindowOrWorkerGlobalScope.btoa

cancelAnimationFrame(number)

function cancelAnimationFrame(handle: number)

参数

handle

number

继承自 AnimationFrameProvider.cancelAnimationFrame

clearInterval(undefined | number)

function clearInterval(id: undefined | number)

参数

id

undefined | number

继承自 WindowOrWorkerGlobalScope.clearInterval

clearTimeout(undefined | number)

function clearTimeout(id: undefined | number)

参数

id

undefined | number

继承自 WindowOrWorkerGlobalScope.clearTimeout

createImageBitmap(ImageBitmapSource, ImageBitmapOptions)

function createImageBitmap(image: ImageBitmapSource, options?: ImageBitmapOptions): Promise<ImageBitmap>

参数

image

ImageBitmapSource

options

ImageBitmapOptions

返回

Promise<ImageBitmap>

继承自 WindowOrWorkerGlobalScope.createImageBitmap

createImageBitmap(ImageBitmapSource, number, number, number, number, ImageBitmapOptions)

function createImageBitmap(image: ImageBitmapSource, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise<ImageBitmap>

参数

image

ImageBitmapSource

sx

number

sy

number

sw

number

sh

number

options

ImageBitmapOptions

返回

Promise<ImageBitmap>

继承自 WindowOrWorkerGlobalScope.createImageBitmap

dispatchEvent(Event)

如果事件的可取消属性值为 false 或其 preventDefault() 方法未调用,则调度合成事件事件的目标并返回 true;否则返回 false。

function dispatchEvent(event: Event): boolean

参数

event

Event

返回

boolean

继承自 EventTarget.dispatchEvent

fetch(URL | RequestInfo, RequestInit)

function fetch(input: URL | RequestInfo, init?: RequestInit): Promise<Response>

参数

input

URL | RequestInfo

init

RequestInit

返回

Promise<Response>

继承自 WindowOrWorkerGlobalScope.fetch

queueMicrotask(VoidFunction)

function queueMicrotask(callback: VoidFunction)

参数

callback

VoidFunction

继承自 WindowOrWorkerGlobalScope.queueMicrotask

reportError(any)

function reportError(e: any)

参数

e

any

继承自 WindowOrWorkerGlobalScope.reportError

requestAnimationFrame(FrameRequestCallback)

function requestAnimationFrame(callback: FrameRequestCallback): number

参数

callback

FrameRequestCallback

返回

number

继承自 AnimationFrameProvider.requestAnimationFrame

setInterval(TimerHandler, number, any[])

function setInterval(handler: TimerHandler, timeout?: number, arguments: any[]): number

参数

handler

TimerHandler

timeout

number

arguments

any[]

返回

number

继承自 WindowOrWorkerGlobalScope.setInterval

setTimeout(TimerHandler, number, any[])

function setTimeout(handler: TimerHandler, timeout?: number, arguments: any[]): number

参数

handler

TimerHandler

timeout

number

arguments

any[]

返回

number

继承自 WindowOrWorkerGlobalScope.setTimeout

structuredClone(any, StructuredSerializeOptions)

function structuredClone(value: any, options?: StructuredSerializeOptions): any

参数

value

any

options

StructuredSerializeOptions

返回

any

继承自 WindowOrWorkerGlobalScope.structuredClone