Skip to content

Global

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

alert

let alert: unit => unit

Parameters

unit

Return type

unit

alert2

let alert2: string => unit

Parameters

string

Return type

unit

atob

let atob: string => string

Parameters

string

Return type

string

btoa

let btoa: string => string

Parameters

string

Return type

string

caches

let caches: WebAPI.ServiceWorkerAPI.cacheStorage

cancelAnimationFrame

let cancelAnimationFrame: int => unit

Parameters

int

Return type

unit

cancelIdleCallback

let cancelIdleCallback: int => unit

Parameters

int

Return type

unit

clearInterval

let clearInterval: int => unit

Parameters

int

Return type

unit

clearTimeout

let clearTimeout: int => unit

Parameters

int

Return type

unit

close

Closes the window. Read more on MDN

let close: unit => unit

Parameters

unit

Return type

unit

closed

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

let closed: bool

confirm

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

Parameters

option< string >

Return type

bool

createImageBitmap

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

createImageBitmap10

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

Parameters

WebAPI.DOMAPI.htmlImageElement int int int int option< WebAPI.DOMAPI.imageBitmapOptions >

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap11

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

Parameters

WebAPI.DOMAPI.svgImageElement int int int int option< WebAPI.DOMAPI.imageBitmapOptions >

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap12

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

Parameters

WebAPI.DOMAPI.htmlVideoElement int int int int option< WebAPI.DOMAPI.imageBitmapOptions >

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap13

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

Parameters

WebAPI.DOMAPI.htmlCanvasElement int int int int option< WebAPI.DOMAPI.imageBitmapOptions >

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap14

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

Parameters

WebAPI.CanvasAPI.imageBitmap int int int int option< WebAPI.DOMAPI.imageBitmapOptions >

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap15

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

Parameters

WebAPI.CanvasAPI.offscreenCanvas int int int int option< WebAPI.DOMAPI.imageBitmapOptions >

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap16

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

Parameters

WebAPI.DOMAPI.videoFrame int int int int option< WebAPI.DOMAPI.imageBitmapOptions >

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap17

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

Parameters

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

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap18

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

Parameters

WebAPI.DOMAPI.imageData int int int int option< WebAPI.DOMAPI.imageBitmapOptions >

Return type

Promise.t< WebAPI.CanvasAPI.imageBitmap >

createImageBitmap2

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

createImageBitmap3

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

createImageBitmap4

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

createImageBitmap5

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

createImageBitmap6

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

createImageBitmap7

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

createImageBitmap8

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

createImageBitmap9

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

crossOriginIsolated

let crossOriginIsolated: bool

crypto

let crypto: WebAPI.WebCryptoAPI.crypto

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: WebAPI.DOMAPI.customElementRegistry

devicePixelRatio

let devicePixelRatio: 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: WebAPI.EventAPI.event => bool

Parameters

WebAPI.EventAPI.event

Return type

bool

document

let document: WebAPI.DOMAPI.document

fetch

fetch(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 fetch("https://rescript-lang.org")

Read more on MDN

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

Parameters

string option< WebAPI.FetchAPI.requestInit >

Return type

Promise.t< WebAPI.FetchAPI.response >

fetch_withRequest

fetch_withRequest(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 fetch(myRequest)

Read more on MDN

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

Parameters

WebAPI.FetchAPI.request option< WebAPI.FetchAPI.requestInit >

Return type

Promise.t< WebAPI.FetchAPI.response >

focus

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

let focus: unit => unit

Parameters

unit

Return type

unit

frameElement

let frameElement: WebAPI.DOMAPI.element

frames

let frames: WebAPI.DOMAPI.window

getComputedStyle

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

Parameters

WebAPI.DOMAPI.element option< string >

Return type

WebAPI.DOMAPI.cssStyleDeclaration

getSelection

let getSelection: unit => WebAPI.DOMAPI.selection

Parameters

unit

Return type

WebAPI.DOMAPI.selection

history

let history: WebAPI.HistoryAPI.history

indexedDB

let indexedDB: WebAPI.IndexedDBAPI.idbFactory

innerHeight

let innerHeight: int

innerWidth

let innerWidth: int

isSecureContext

let isSecureContext: bool

length

let length: int

localStorage

let localStorage: WebAPI.WebStorageAPI.storage

location

let location: WebAPI.DOMAPI.location

locationbar

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

let locationbar: WebAPI.DOMAPI.barProp

matchMedia

let matchMedia: string => WebAPI.DOMAPI.mediaQueryList

Parameters

string

Return type

WebAPI.DOMAPI.mediaQueryList

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

let menubar: WebAPI.DOMAPI.barProp

moveBy

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

Parameters

int int

Return type

unit

moveTo

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

Parameters

int int

Return type

unit

name

let name: string
let navigator: WebAPI.DOMAPI.navigator

open_

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

Parameters

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

Return type

WebAPI.DOMAPI.window

opener

let opener: JSON.t

origin

let origin: string

outerHeight

let outerHeight: int

outerWidth

let outerWidth: 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: WebAPI.DOMAPI.window

performance

let performance: WebAPI.PerformanceAPI.performance

personalbar

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

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

Parameters

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

Parameters

JSON.t option< WebAPI.DOMAPI.windowPostMessageOptions >

Return type

unit

print

let print: unit => unit

Parameters

unit

Return type

unit

prompt

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

Parameters

option< string > option< string >

Return type

string

queueMicrotask

let queueMicrotask: WebAPI.DOMAPI.voidFunction => unit

Parameters

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

Parameters

string WebAPI.EventAPI.eventListener option< WebAPI.EventAPI.eventListenerOptions >

Return type

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

reportError

let reportError: JSON.t => unit

Parameters

JSON.t

Return type

unit

requestAnimationFrame

let requestAnimationFrame: WebAPI.DOMAPI.frameRequestCallback => int

Parameters

WebAPI.DOMAPI.frameRequestCallback

Return type

int

requestIdleCallback

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

resizeBy

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

Parameters

int int

Return type

unit

resizeTo

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

Parameters

int int

Return type

unit

screen

let screen: WebAPI.DOMAPI.screen

screenLeft

let screenLeft: int

screenTop

let screenTop: int

screenX

let screenX: int

screenY

let screenY: int

scroll

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

Parameters

option< WebAPI.DOMAPI.scrollToOptions >

Return type

unit

scroll2

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

Parameters

float float

Return type

unit

scrollbars

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

let scrollbars: WebAPI.DOMAPI.barProp

scrollBy

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

Parameters

option< WebAPI.DOMAPI.scrollToOptions >

Return type

unit

scrollBy2

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

Parameters

float float

Return type

unit

scrollTo

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

Parameters

option< WebAPI.DOMAPI.scrollToOptions >

Return type

unit

scrollTo2

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

Parameters

float float

Return type

unit

scrollX

let scrollX: float

scrollY

let scrollY: float

self

let self: WebAPI.DOMAPI.window

sessionStorage

let sessionStorage: WebAPI.WebStorageAPI.storage

setInterval

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

Parameters

string option< int >

Return type

int

setInterval2

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

Parameters

unit unit option< int >

Return type

int

setTimeout

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

Parameters

string option< int >

Return type

int

setTimeout2

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

Parameters

unit unit option< int >

Return type

int

speechSynthesis

let speechSynthesis: WebAPI.WebSpeechAPI.speechSynthesis

statusbar

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

let statusbar: WebAPI.DOMAPI.barProp

stop

Cancels the document load. Read more on MDN

let stop: unit => unit

Parameters

unit

Return type

unit

structuredClone

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

toolbar

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

let toolbar: WebAPI.DOMAPI.barProp

top

let top: WebAPI.DOMAPI.window

visualViewport

let visualViewport: WebAPI.VisualViewportAPI.visualViewport

window

let window: WebAPI.DOMAPI.window