Skip to content

Window

Types

t

type t = DomTypes.window

windowPostMessageOptions

type windowPostMessageOptions = DomTypes.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,
EventTypes.eventType,
EventTypes.eventListener<'event>,
~options: EventTypes.addEventListenerOptions=?,
) => unit

Parameters

t EventTypes.eventType EventTypes.eventListener option< EventTypes.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,
EventTypes.eventType,
EventTypes.eventListener<'event>,
) => unit

Parameters

t EventTypes.eventType EventTypes.eventListener

Return type

unit

alert

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

Parameters

t option< string >

Return type

unit

asEventTarget

let asEventTarget: t => EventTypes.eventTarget

Parameters

t

Return type

EventTypes.eventTarget

atob

let atob: (t, string) => string

Parameters

t string

Return type

string

btoa

let btoa: (t, string) => string

Parameters

t string

Return type

string

caches

let caches: t => WebWorkersTypes.cacheStorage

Parameters

t

Return type

WebWorkersTypes.cacheStorage

cancelAnimationFrame

let cancelAnimationFrame: (t, int) => unit

Parameters

t int

Return type

unit

cancelIdleCallback

let cancelIdleCallback: (t, int) => unit

Parameters

t int

Return type

unit

clearInterval

let clearInterval: (t, int) => unit

Parameters

t int

Return type

unit

clearTimeout

Cancels the execution of a timeout created with setTimeout.

Read more on MDN

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

Parameters

t DomTypes.timeoutId

Return type

unit

close

Closes the window. Read more on MDN

let close: t => unit

Parameters

t

Return type

unit

closed

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

let closed: t => bool

Parameters

t

Return type

bool

confirm

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

Parameters

t option< string >

Return type

bool

crossOriginIsolated

let crossOriginIsolated: t => bool

Parameters

t

Return type

bool

crypto

let crypto: t => WebCryptoTypes.crypto

Parameters

t

Return type

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 => DomTypes.customElementRegistry

Parameters

t

Return type

DomTypes.customElementRegistry

devicePixelRatio

let devicePixelRatio: t => float

Parameters

t

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, EventTypes.event) => bool

Parameters

t EventTypes.event

Return type

bool

document

let document: t => DomTypes.document

Parameters

t

Return type

DomTypes.document

focus

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

let focus: t => unit

Parameters

t

Return type

unit

frameElement

let frameElement: t => Null.t<DomTypes.element>

Parameters

t

Return type

Stdlib.Null.t< DomTypes.element >

frames

let frames: t => t

Parameters

t

Return type

t

getComputedStyle

let getComputedStyle: (
t,
~elt: DomTypes.element,
~pseudoElt: string=?,
) => DomTypes.cssStyleDeclaration

Parameters

t DomTypes.element option< string >

Return type

DomTypes.cssStyleDeclaration

getSelection

let getSelection: t => null<DomTypes.selection>

Parameters

t

Return type

Stdlib.null< DomTypes.selection >

history

let history: t => HistoryTypes.history

Parameters

t

Return type

HistoryTypes.history

indexedDB

let indexedDB: t => IndexedDbTypes.idbFactory

Parameters

t

Return type

IndexedDbTypes.idbFactory

innerHeight

let innerHeight: t => int

Parameters

t

Return type

int

innerWidth

let innerWidth: t => int

Parameters

t

Return type

int

isSecureContext

let isSecureContext: t => bool

Parameters

t

Return type

bool

length

let length: t => int

Parameters

t

Return type

int

localStorage

let localStorage: t => WebStorageTypes.storage

Parameters

t

Return type

WebStorageTypes.storage

location

let location: t => DomTypes.location

Parameters

t

Return type

DomTypes.location

locationbar

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

let locationbar: t => DomTypes.barProp

Parameters

t

Return type

DomTypes.barProp

matchMedia

let matchMedia: (t, string) => DomTypes.mediaQueryList

Parameters

t string

Return type

DomTypes.mediaQueryList

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

let menubar: t => DomTypes.barProp

Parameters

t

Return type

DomTypes.barProp

moveBy

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

Parameters

t int int

Return type

unit

moveTo

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

Parameters

t int int

Return type

unit

name

let name: t => string

Parameters

t

Return type

string
let navigator: t => DomTypes.navigator

Parameters

t

Return type

DomTypes.navigator

open_

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

Parameters

t option< string > option< string > option< string >

Return type

t

opener

let opener: t => JSON.t

Parameters

t

Return type

Stdlib.JSON.t

origin

let origin: t => string

Parameters

t

Return type

string

outerHeight

let outerHeight: t => int

Parameters

t

Return type

int

outerWidth

let outerWidth: t => int

Parameters

t

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 => t

Parameters

t

Return type

t

performance

let performance: t => PerformanceTypes.performance

Parameters

t

Return type

PerformanceTypes.performance

personalbar

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

let personalbar: t => DomTypes.barProp

Parameters

t

Return type

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

t Stdlib.JSON.t string option< array< Stdlib.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

t Stdlib.JSON.t option< windowPostMessageOptions >

Return type

unit

print

let print: t => unit

Parameters

t

Return type

unit

prompt

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

Parameters

t option< string > option< string >

Return type

string

queueMicrotask

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

Parameters

t 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,
EventTypes.eventType,
EventTypes.eventListener<'event>,
~options: EventTypes.eventListenerOptions=?,
) => unit

Parameters

t EventTypes.eventType EventTypes.eventListener option< EventTypes.eventListenerOptions >

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,
EventTypes.eventType,
EventTypes.eventListener<'event>,
) => unit

Parameters

t EventTypes.eventType EventTypes.eventListener

Return type

unit

reportError

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

Parameters

t Stdlib.JSON.t

Return type

unit

requestAnimationFrame

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

Parameters

t float unit

Return type

int

requestIdleCallback

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

Parameters

t DomTypes.idleDeadline unit option< DomTypes.idleRequestOptions >

Return type

int

resizeBy

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

Parameters

t int int

Return type

unit

resizeTo

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

Parameters

t int int

Return type

unit

screen

let screen: t => DomTypes.screen

Parameters

t

Return type

DomTypes.screen

screenLeft

let screenLeft: t => int

Parameters

t

Return type

int

screenTop

let screenTop: t => int

Parameters

t

Return type

int

screenX

let screenX: t => int

Parameters

t

Return type

int

screenY

let screenY: t => int

Parameters

t

Return type

int

scroll

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

Parameters

t option< DomTypes.scrollToOptions >

Return type

unit

scrollbars

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

let scrollbars: t => DomTypes.barProp

Parameters

t

Return type

DomTypes.barProp

scrollBy

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

Parameters

t option< DomTypes.scrollToOptions >

Return type

unit

scrollByXY

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

Parameters

t float float

Return type

unit

scrollTo

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

Parameters

t option< DomTypes.scrollToOptions >

Return type

unit

scrollToXY

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

Parameters

t float float

Return type

unit

scrollX

let scrollX: t => float

Parameters

t

Return type

float

scrollXY

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

Parameters

t float float

Return type

unit

scrollY

let scrollY: t => float

Parameters

t

Return type

float

self

let self: t => t

Parameters

t

Return type

t

sessionStorage

let sessionStorage: t => WebStorageTypes.storage

Parameters

t

Return type

WebStorageTypes.storage

setInterval

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

Parameters

t string option< int >

Return type

int

setInterval2

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

Parameters

t unit unit option< int >

Return type

int

setIntervalWithCallback

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

Parameters

t unit unit option< 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=?,
) => DomTypes.timeoutId

Parameters

t unit unit option< int >

Return type

DomTypes.timeoutId

speechSynthesis

let speechSynthesis: t => WebSpeechTypes.speechSynthesis

Parameters

t

Return type

WebSpeechTypes.speechSynthesis

statusbar

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

let statusbar: t => DomTypes.barProp

Parameters

t

Return type

DomTypes.barProp

stop

Cancels the document load. Read more on MDN

let stop: t => unit

Parameters

t

Return type

unit

structuredClone

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

Parameters

t

Return type

option< ChannelMessagingTypes.structuredSerializeOptions >

toolbar

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

let toolbar: t => DomTypes.barProp

Parameters

t

Return type

DomTypes.barProp

top

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

Parameters

t

Return type

Stdlib.Null.t< t >

visualViewport

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

Parameters

t

Return type

Stdlib.Null.t< VisualViewport.t >

window

let window: t => t

Parameters

t

Return type

t