Skip to content

Window

Types

t

type t = WebAPI.DOM.window

windowPostMessageOptions

type windowPostMessageOptions = WebAPI.DOM.windowPostMessageOptions

Record fields

transfer
option<array<Dict.t<string>>>
targetOrigin
option<string>

Values

addEventListener

Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. Read more on MDN

let addEventListener: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
~options: WebAPI.DOM.EventListener.addEventListenerOptions=?,
) => unit

Parameters

WebAPI.DOM.EventListener.t<'event>
~options: WebAPI.DOM.EventListener.addEventListenerOptions=?

Return type

unit

addEventListenerWithCapture

Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture. Read more on MDN

let addEventListenerWithCapture: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
) => unit

Parameters

WebAPI.DOM.EventListener.t<'event>

Return type

unit

alert

let alert: (t, ~message: string=?) => unit

Parameters

~message: string=?

Return type

unit

asEventTarget

let asEventTarget: t => WebAPI.DOM.eventTarget

Parameters

Return type

WebAPI.DOM.eventTarget

atob

let atob: (t, string) => string

Parameters

string

Return type

string

btoa

let btoa: (t, string) => string

Parameters

string

Return type

string

caches

let caches: t => WebAPI.CacheTypes.cacheStorage

Parameters

Return type

WebAPI.CacheTypes.cacheStorage

cancelAnimationFrame

let cancelAnimationFrame: (t, int) => unit

Parameters

int

Return type

unit

cancelIdleCallback

let cancelIdleCallback: (t, int) => unit

Parameters

int

Return type

unit

clearInterval

let clearInterval: (t, int) => unit

Parameters

int

Return type

unit

clearTimeout

Cancels the execution of a timeout created with setTimeout.

Read more on MDN

let clearTimeout: (t, WebAPI.DOM.timeoutId) => unit

Parameters

Return type

unit

close

Closes the window. Read more on MDN

let close: t => unit

Parameters

Return type

unit

closed

Returns true if the window has been closed, false otherwise. Read more on MDN

let closed: t => bool

Parameters

Return type

bool

confirm

let confirm: (t, ~message: string=?) => bool

Parameters

~message: string=?

Return type

bool

crossOriginIsolated

let crossOriginIsolated: t => bool

Parameters

Return type

bool

crypto

let crypto: t => WebAPI.WebCryptoTypes.crypto

Parameters

Return type

WebAPI.WebCryptoTypes.crypto

current

let current: t

customElements

Defines a new custom element, mapping the given name to the given constructor as an autonomous custom element. Read more on MDN

let customElements: t => WebAPI.DOM.customElementRegistry

devicePixelRatio

let devicePixelRatio: t => float

Parameters

Return type

float

dispatchEvent

Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. Read more on MDN

let dispatchEvent: (t, WebAPI.DOM.event) => bool

Parameters

Return type

bool

document

let document: t => WebAPI.DOM.document

Parameters

Return type

WebAPI.DOM.document

focus

Moves the focus to the window's browsing context, if any. Read more on MDN

let focus: t => unit

Parameters

Return type

unit

frameElement

let frameElement: t => Null.t<WebAPI.DOMTree.element>

Parameters

Return type

Null.t<WebAPI.DOMTree.element>

frames

let frames: t => t

Parameters

Return type

t

getComputedStyle

let getComputedStyle: (
t,
~elt: WebAPI.DOMTree.element,
~pseudoElt: string=?,
) => WebAPI.CSSStyleDeclaration.t

Parameters

~pseudoElt: string=?

Return type

WebAPI.CSSStyleDeclaration.t

getSelection

let getSelection: t => Null.t<WebAPI.Selection.t>

Parameters

Return type

Null.t<WebAPI.Selection.t>

history

let history: t => WebAPI.HistoryTypes.history

Parameters

Return type

WebAPI.HistoryTypes.history

indexedDB

let indexedDB: t => WebAPI.IndexedDbTypes.idbFactory

innerHeight

let innerHeight: t => int

Parameters

Return type

int

innerWidth

let innerWidth: t => int

Parameters

Return type

int

isSecureContext

let isSecureContext: t => bool

Parameters

Return type

bool

length

let length: t => int

Parameters

Return type

int

localStorage

let localStorage: t => WebAPI.WebStorageTypes.storage

Parameters

Return type

WebAPI.WebStorageTypes.storage

location

let location: t => WebAPI.Location.t

Parameters

Return type

WebAPI.Location.t

locationbar

Returns true if the location bar is visible; otherwise, returns false. Read more on MDN

let locationbar: t => WebAPI.DOM.barProp

Parameters

Return type

WebAPI.DOM.barProp

matchMedia

let matchMedia: (t, string) => WebAPI.MediaQueryList.t

Parameters

string

Return type

WebAPI.MediaQueryList.t

Returns true if the menu bar is visible; otherwise, returns false. Read more on MDN

let menubar: t => WebAPI.DOM.barProp

Parameters

Return type

WebAPI.DOM.barProp

moveBy

let moveBy: (t, ~x: int, ~y: int) => unit

Parameters

~x: int
~y: int

Return type

unit

moveTo

let moveTo: (t, ~x: int, ~y: int) => unit

Parameters

~x: int
~y: int

Return type

unit

name

let name: t => string

Parameters

Return type

string
let navigator: t => WebAPI.DOM.navigator

Parameters

Return type

WebAPI.DOM.navigator

open_

let open_: (
t,
~url: string=?,
~target: string=?,
~features: string=?,
) => Null.t<t>

Parameters

~url: string=?
~target: string=?
~features: string=?

Return type

Null.t<t>

opener

let opener: t => JSON.t

Parameters

Return type

JSON.t

origin

let origin: t => string

Parameters

Return type

string

outerHeight

let outerHeight: t => int

Parameters

Return type

int

outerWidth

let outerWidth: t => int

Parameters

Return type

int

parent

Refers to either the parent WindowProxy, or itself.

It can rarely be null e.g. for contentWindow of an iframe that is already removed from the parent. Read more on MDN

let parent: t => Null.t<t>

Parameters

Return type

Null.t<t>

performance

let performance: t => WebAPI.PerformanceTypes.performance

Parameters

Return type

WebAPI.PerformanceTypes.performance

personalbar

Returns true if the personal bar is visible; otherwise, returns false. Read more on MDN

let personalbar: t => WebAPI.DOM.barProp

Parameters

Return type

WebAPI.DOM.barProp

postMessage

Posts a message to the given window. Messages can be structured objects, e.g. nested objects and arrays, can contain JavaScript values (strings, numbers, Date objects, etc), and can contain certain data objects such as WebApiFile Blob, FileList, and ArrayBuffer objects.

Objects listed in the transfer member of options are transferred, not just cloned, meaning that they are no longer usable on the sending side.

A target origin can be specified using the targetOrigin member of options. If not provided, it defaults to "/". This default restricts the message to same-origin targets only.

If the origin of the target window doesn't match the given target origin, the message is discarded, to avoid information leakage. To send the message to the target regardless of origin, set the target origin to "*".

Throws a "DataCloneError" DOMException if transfer array contains duplicate objects or if message could not be cloned. Read more on MDN

let postMessage: (
t,
~message: JSON.t,
~targetOrigin: string,
~transfer: array<Dict.t<string>>=?,
) => unit

Parameters

~message: JSON.t
~targetOrigin: string
~transfer: array<Dict.t<string>>=?

Return type

unit

postMessageWithOptions

Posts a message to the given window. Messages can be structured objects, e.g. nested objects and arrays, can contain JavaScript values (strings, numbers, Date objects, etc), and can contain certain data objects such as WebApiFile Blob, FileList, and ArrayBuffer objects.

Objects listed in the transfer member of options are transferred, not just cloned, meaning that they are no longer usable on the sending side.

A target origin can be specified using the targetOrigin member of options. If not provided, it defaults to "/". This default restricts the message to same-origin targets only.

If the origin of the target window doesn't match the given target origin, the message is discarded, to avoid information leakage. To send the message to the target regardless of origin, set the target origin to "*".

Throws a "DataCloneError" DOMException if transfer array contains duplicate objects or if message could not be cloned. Read more on MDN

let postMessageWithOptions: (
t,
~message: JSON.t,
~options: windowPostMessageOptions=?,
) => unit

Parameters

~message: JSON.t

Return type

unit

print

let print: t => unit

Parameters

Return type

unit

prompt

let prompt: (
t,
~message: string=?,
~default: string=?,
) => Null.t<string>

Parameters

~message: string=?
~default: string=?

Return type

Null.t<string>

queueMicrotask

let queueMicrotask: (t, unit => unit) => unit

Parameters

(unit) => unit

Return type

unit

removeEventListener

Removes the event listener in target's event listener list with the same type, callback, and options. Read more on MDN

let removeEventListener: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
~options: WebAPI.DOM.EventListener.options=?,
) => unit

Parameters

WebAPI.DOM.EventListener.t<'event>
~options: WebAPI.DOM.EventListener.options=?

Return type

unit

removeEventListenerUseCapture

Removes the event listener in target's event listener list with the same type, callback, and options. Read more on MDN

let removeEventListenerUseCapture: (
t,
WebAPI.EventType.t,
WebAPI.DOM.EventListener.t<'event>,
) => unit

Parameters

WebAPI.DOM.EventListener.t<'event>

Return type

unit

reportError

let reportError: (t, JSON.t) => unit

Parameters

JSON.t

Return type

unit

requestAnimationFrame

let requestAnimationFrame: (t, float => unit) => int

Parameters

(float) => unit

Return type

int

requestIdleCallback

let requestIdleCallback: (
t,
~callback: WebAPI.DOM.idleDeadline => unit,
~options: WebAPI.DOM.idleRequestOptions=?,
) => int

Parameters

~callback: (WebAPI.DOM.idleDeadline) => unit

Return type

int

resizeBy

let resizeBy: (t, ~x: int, ~y: int) => unit

Parameters

~x: int
~y: int

Return type

unit

resizeTo

let resizeTo: (t, ~width: int, ~height: int) => unit

Parameters

~width: int
~height: int

Return type

unit

screen

let screen: t => WebAPI.DOM.screen

Parameters

Return type

WebAPI.DOM.screen

screenLeft

let screenLeft: t => int

Parameters

Return type

int

screenTop

let screenTop: t => int

Parameters

Return type

int

screenX

let screenX: t => int

Parameters

Return type

int

screenY

let screenY: t => int

Parameters

Return type

int

scroll

let scroll: (t, ~options: WebAPI.DOM.scrollToOptions=?) => unit

Parameters

Return type

unit

scrollbars

Returns true if the scrollbars are visible; otherwise, returns false. Read more on MDN

let scrollbars: t => WebAPI.DOM.barProp

Parameters

Return type

WebAPI.DOM.barProp

scrollBy

let scrollBy: (t, ~options: WebAPI.DOM.scrollToOptions=?) => unit

Parameters

Return type

unit

scrollByXY

let scrollByXY: (t, ~x: float, ~y: float) => unit

Parameters

~x: float
~y: float

Return type

unit

scrollTo

let scrollTo: (t, ~options: WebAPI.DOM.scrollToOptions=?) => unit

Parameters

Return type

unit

scrollToXY

let scrollToXY: (t, ~x: float, ~y: float) => unit

Parameters

~x: float
~y: float

Return type

unit

scrollX

let scrollX: t => float

Parameters

Return type

float

scrollXY

let scrollXY: (t, ~x: float, ~y: float) => unit

Parameters

~x: float
~y: float

Return type

unit

scrollY

let scrollY: t => float

Parameters

Return type

float

self

let self: t => t

Parameters

Return type

t

sessionStorage

let sessionStorage: t => WebAPI.WebStorageTypes.storage

Parameters

Return type

WebAPI.WebStorageTypes.storage

setInterval

let setInterval: (t, ~handler: string, ~timeout: int=?) => int

Parameters

~handler: string
~timeout: int=?

Return type

int

setInterval2

let setInterval2: (t, ~handler: unit => unit, ~timeout: int=?) => int

Parameters

~handler: (unit) => unit
~timeout: int=?

Return type

int

setIntervalWithCallback

let setIntervalWithCallback: (t, ~handler: unit => unit, ~timeout: int=?) => int

Parameters

~handler: (unit) => unit
~timeout: int=?

Return type

int

setTimeout

Executes a function after a delay given in milliseconds expires.

Read more on MDN

let setTimeout: (
t,
~handler: unit => unit,
~timeout: int=?,
) => WebAPI.DOM.timeoutId

Parameters

~handler: (unit) => unit
~timeout: int=?

Return type

WebAPI.DOM.timeoutId

speechSynthesis

let speechSynthesis: t => WebAPI.WebSpeechTypes.speechSynthesis

Parameters

Return type

WebAPI.WebSpeechTypes.speechSynthesis

statusbar

Returns true if the status bar is visible; otherwise, returns false. Read more on MDN

let statusbar: t => WebAPI.DOM.barProp

Parameters

Return type

WebAPI.DOM.barProp

stop

Cancels the document load. Read more on MDN

let stop: t => unit

Parameters

Return type

unit

structuredClone

let structuredClone: (
t,
't,
~options: WebAPI.ChannelMessagingTypes.structuredSerializeOptions=?,
) => 't

toolbar

Returns true if the toolbar is visible; otherwise, returns false. Read more on MDN

let toolbar: t => WebAPI.DOM.barProp

Parameters

Return type

WebAPI.DOM.barProp

top

let top: t => Null.t<t>

Parameters

Return type

Null.t<t>

visualViewport

let visualViewport: t => Null.t<WebAPI.VisualViewport.t>

Parameters

Return type

Null.t<WebAPI.VisualViewport.t>

window

let window: t => t

Parameters

Return type

t