Skip to content

Window

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: (
WebAPI.DOMAPI.window,
~type_: WebAPI.EventAPI.eventType,
~callback: WebAPI.EventAPI.eventListener<'event>,
~options: WebAPI.EventAPI.addEventListenerOptions=?,
) => unit

addEventListener_useCapture

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_useCapture: (
WebAPI.DOMAPI.window,
~type_: WebAPI.EventAPI.eventType,
~callback: WebAPI.EventAPI.eventListener<'event>,
) => unit

alert

let alert: WebAPI.DOMAPI.window => unit

Parameters

WebAPI.DOMAPI.window

Return type

unit

alert2

let alert2: (WebAPI.DOMAPI.window, string) => unit

Parameters

WebAPI.DOMAPI.window string

Return type

unit

asEventTarget

let asEventTarget: WebAPI.DOMAPI.window => WebAPI.EventAPI.eventTarget

atob

let atob: (WebAPI.DOMAPI.window, string) => string

Parameters

WebAPI.DOMAPI.window string

Return type

string

btoa

let btoa: (WebAPI.DOMAPI.window, string) => string

Parameters

WebAPI.DOMAPI.window string

Return type

string

cancelAnimationFrame

let cancelAnimationFrame: (WebAPI.DOMAPI.window, int) => unit

Parameters

WebAPI.DOMAPI.window int

Return type

unit

cancelIdleCallback

let cancelIdleCallback: (WebAPI.DOMAPI.window, int) => unit

Parameters

WebAPI.DOMAPI.window int

Return type

unit

clearInterval

let clearInterval: (WebAPI.DOMAPI.window, int) => unit

Parameters

WebAPI.DOMAPI.window int

Return type

unit

clearTimeout

let clearTimeout: (WebAPI.DOMAPI.window, int) => unit

Parameters

WebAPI.DOMAPI.window int

Return type

unit

close

Closes the window. Read more on MDN

let close: WebAPI.DOMAPI.window => unit

Parameters

WebAPI.DOMAPI.window

Return type

unit

confirm

let confirm: (WebAPI.DOMAPI.window, ~message: string=?) => bool

Parameters

WebAPI.DOMAPI.window option< string >

Return type

bool

createImageBitmap

let createImageBitmap: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.htmlImageElement,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap10

let createImageBitmap10: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.htmlImageElement,
~sx: int,
~sy: int,
~sw: int,
~sh: int,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap11

let createImageBitmap11: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.svgImageElement,
~sx: int,
~sy: int,
~sw: int,
~sh: int,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap12

let createImageBitmap12: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.htmlVideoElement,
~sx: int,
~sy: int,
~sw: int,
~sh: int,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap13

let createImageBitmap13: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.htmlCanvasElement,
~sx: int,
~sy: int,
~sw: int,
~sh: int,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap14

let createImageBitmap14: (
WebAPI.DOMAPI.window,
~image: WebAPI.CanvasAPI.imageBitmap,
~sx: int,
~sy: int,
~sw: int,
~sh: int,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap15

let createImageBitmap15: (
WebAPI.DOMAPI.window,
~image: WebAPI.CanvasAPI.offscreenCanvas,
~sx: int,
~sy: int,
~sw: int,
~sh: int,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap16

let createImageBitmap16: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.videoFrame,
~sx: int,
~sy: int,
~sw: int,
~sh: int,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap17

let createImageBitmap17: (
WebAPI.DOMAPI.window,
~image: WebAPI.FileAPI.blob,
~sx: int,
~sy: int,
~sw: int,
~sh: int,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

Parameters

WebAPI.DOMAPI.window WebAPI.FileAPI.blob int int int int option< WebAPI.DOMAPI.imageBitmapOptions >

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap18

let createImageBitmap18: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.imageData,
~sx: int,
~sy: int,
~sw: int,
~sh: int,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap2

let createImageBitmap2: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.svgImageElement,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap3

let createImageBitmap3: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.htmlVideoElement,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap4

let createImageBitmap4: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.htmlCanvasElement,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap5

let createImageBitmap5: (
WebAPI.DOMAPI.window,
~image: WebAPI.CanvasAPI.imageBitmap,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap6

let createImageBitmap6: (
WebAPI.DOMAPI.window,
~image: WebAPI.CanvasAPI.offscreenCanvas,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap7

let createImageBitmap7: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.videoFrame,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap8

let createImageBitmap8: (
WebAPI.DOMAPI.window,
~image: WebAPI.FileAPI.blob,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

createImageBitmap9

let createImageBitmap9: (
WebAPI.DOMAPI.window,
~image: WebAPI.DOMAPI.imageData,
~options: WebAPI.DOMAPI.imageBitmapOptions=?,
) => Promise.t<WebAPI.CanvasAPI.imageBitmap>

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: (WebAPI.DOMAPI.window, WebAPI.EventAPI.event) => bool

Parameters

WebAPI.DOMAPI.window WebAPI.EventAPI.event

Return type

bool

fetch

fetch(window, string, init)

Starts the process of fetching a resource from the network, returning a promise that is fulfilled once the response is available.

let response = await window->Window.fetch("https://rescript-lang.org")

Read more on MDN

let fetch: (
WebAPI.DOMAPI.window,
string,
~init: WebAPI.FetchAPI.requestInit=?,
) => Promise.t<WebAPI.FetchAPI.response>

Parameters

WebAPI.DOMAPI.window string option< WebAPI.FetchAPI.requestInit >

Return type

Promise.t< WebAPI.FetchAPI.response >

fetch_withRequest

fetch_withRequest(window, request, init)

Starts the process of fetching a resource from the network, returning a promise that is fulfilled once the response is available.

let response = await window->Window.fetch(myRequest)

Read more on MDN

let fetch_withRequest: (
WebAPI.DOMAPI.window,
WebAPI.FetchAPI.request,
~init: WebAPI.FetchAPI.requestInit=?,
) => Promise.t<WebAPI.FetchAPI.response>

focus

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

let focus: WebAPI.DOMAPI.window => unit

Parameters

WebAPI.DOMAPI.window

Return type

unit

getComputedStyle

let getComputedStyle: (
WebAPI.DOMAPI.window,
~elt: WebAPI.DOMAPI.element,
~pseudoElt: string=?,
) => WebAPI.DOMAPI.cssStyleDeclaration

getSelection

let getSelection: WebAPI.DOMAPI.window => WebAPI.DOMAPI.selection

matchMedia

let matchMedia: (
WebAPI.DOMAPI.window,
string,
) => WebAPI.DOMAPI.mediaQueryList

Parameters

WebAPI.DOMAPI.window string

Return type

WebAPI.DOMAPI.mediaQueryList

moveBy

let moveBy: (WebAPI.DOMAPI.window, ~x: int, ~y: int) => unit

Parameters

WebAPI.DOMAPI.window int int

Return type

unit

moveTo

let moveTo: (WebAPI.DOMAPI.window, ~x: int, ~y: int) => unit

Parameters

WebAPI.DOMAPI.window int int

Return type

unit

open_

let open_: (
WebAPI.DOMAPI.window,
~url: string=?,
~target: string=?,
~features: string=?,
) => WebAPI.DOMAPI.window

Parameters

WebAPI.DOMAPI.window option< string > option< string > option< string >

Return type

WebAPI.DOMAPI.window

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 File 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: (
WebAPI.DOMAPI.window,
~message: JSON.t,
~targetOrigin: string,
~transfer: array<Dict.t<string>>=?,
) => unit

Parameters

WebAPI.DOMAPI.window JSON.t string option< array< Dict.t< string > > >

Return type

unit

postMessage2

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 File 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 postMessage2: (
WebAPI.DOMAPI.window,
~message: JSON.t,
~options: WebAPI.DOMAPI.windowPostMessageOptions=?,
) => unit

Parameters

WebAPI.DOMAPI.window JSON.t option< WebAPI.DOMAPI.windowPostMessageOptions >

Return type

unit

print

let print: WebAPI.DOMAPI.window => unit

Parameters

WebAPI.DOMAPI.window

Return type

unit

prompt

let prompt: (
WebAPI.DOMAPI.window,
~message: string=?,
~default: string=?,
) => string

Parameters

WebAPI.DOMAPI.window option< string > option< string >

Return type

string

queueMicrotask

let queueMicrotask: (WebAPI.DOMAPI.window, WebAPI.DOMAPI.voidFunction) => unit

Parameters

WebAPI.DOMAPI.window WebAPI.DOMAPI.voidFunction

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: (
WebAPI.DOMAPI.window,
~type_: WebAPI.EventAPI.eventType,
~callback: WebAPI.EventAPI.eventListener<'event>,
~options: WebAPI.EventAPI.eventListenerOptions=?,
) => unit

removeEventListener_useCapture

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

let removeEventListener_useCapture: (
WebAPI.DOMAPI.window,
~type_: WebAPI.EventAPI.eventType,
~callback: WebAPI.EventAPI.eventListener<'event>,
) => unit

reportError

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

Parameters

WebAPI.DOMAPI.window JSON.t

Return type

unit

requestAnimationFrame

let requestAnimationFrame: (
WebAPI.DOMAPI.window,
WebAPI.DOMAPI.frameRequestCallback,
) => int

requestIdleCallback

let requestIdleCallback: (
WebAPI.DOMAPI.window,
~callback: WebAPI.DOMAPI.idleRequestCallback,
~options: WebAPI.DOMAPI.idleRequestOptions=?,
) => int

resizeBy

let resizeBy: (WebAPI.DOMAPI.window, ~x: int, ~y: int) => unit

Parameters

WebAPI.DOMAPI.window int int

Return type

unit

resizeTo

let resizeTo: (WebAPI.DOMAPI.window, ~width: int, ~height: int) => unit

Parameters

WebAPI.DOMAPI.window int int

Return type

unit

scroll

let scroll: (
WebAPI.DOMAPI.window,
~options: WebAPI.DOMAPI.scrollToOptions=?,
) => unit

Parameters

WebAPI.DOMAPI.window option< WebAPI.DOMAPI.scrollToOptions >

Return type

unit

scroll2

let scroll2: (WebAPI.DOMAPI.window, ~x: float, ~y: float) => unit

Parameters

WebAPI.DOMAPI.window float float

Return type

unit

scrollBy

let scrollBy: (
WebAPI.DOMAPI.window,
~options: WebAPI.DOMAPI.scrollToOptions=?,
) => unit

Parameters

WebAPI.DOMAPI.window option< WebAPI.DOMAPI.scrollToOptions >

Return type

unit

scrollBy2

let scrollBy2: (WebAPI.DOMAPI.window, ~x: float, ~y: float) => unit

Parameters

WebAPI.DOMAPI.window float float

Return type

unit

scrollTo

let scrollTo: (
WebAPI.DOMAPI.window,
~options: WebAPI.DOMAPI.scrollToOptions=?,
) => unit

Parameters

WebAPI.DOMAPI.window option< WebAPI.DOMAPI.scrollToOptions >

Return type

unit

scrollTo2

let scrollTo2: (WebAPI.DOMAPI.window, ~x: float, ~y: float) => unit

Parameters

WebAPI.DOMAPI.window float float

Return type

unit

setInterval

let setInterval: (
WebAPI.DOMAPI.window,
~handler: string,
~timeout: int=?,
) => int

Parameters

WebAPI.DOMAPI.window string option< int >

Return type

int

setInterval2

let setInterval2: (
WebAPI.DOMAPI.window,
~handler: unit => unit,
~timeout: int=?,
) => int

Parameters

WebAPI.DOMAPI.window unit unit option< int >

Return type

int

setTimeout

let setTimeout: (
WebAPI.DOMAPI.window,
~handler: string,
~timeout: int=?,
) => int

Parameters

WebAPI.DOMAPI.window string option< int >

Return type

int

setTimeout2

let setTimeout2: (
WebAPI.DOMAPI.window,
~handler: unit => unit,
~timeout: int=?,
) => int

Parameters

WebAPI.DOMAPI.window unit unit option< int >

Return type

int

stop

Cancels the document load. Read more on MDN

let stop: WebAPI.DOMAPI.window => unit

Parameters

WebAPI.DOMAPI.window

Return type

unit

structuredClone

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