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
letaddEventListener: (WebAPI.DOMAPI.window,WebAPI.EventAPI.eventType,WebAPI.EventAPI.eventListener<'event>,~options:WebAPI.EventAPI.addEventListenerOptions=?,)=>unitParameters
WebAPI.DOMAPI.windowWebAPI.EventAPI.eventTypeWebAPI.EventAPI.eventListener option<WebAPI.EventAPI.addEventListenerOptions >Return type
unitaddEventListenerWithCapture
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
letaddEventListenerWithCapture: (WebAPI.DOMAPI.window,WebAPI.EventAPI.eventType,WebAPI.EventAPI.eventListener<'event>,)=>unitParameters
WebAPI.DOMAPI.windowWebAPI.EventAPI.eventTypeWebAPI.EventAPI.eventListenerReturn type
unitalert
letalert:WebAPI.DOMAPI.window=>unitalert2
letalert2: (WebAPI.DOMAPI.window,string)=>unitasEventTarget
letasEventTarget:WebAPI.DOMAPI.window=>WebAPI.EventAPI.eventTargetatob
letatob: (WebAPI.DOMAPI.window,string)=>stringbtoa
letbtoa: (WebAPI.DOMAPI.window,string)=>stringcancelAnimationFrame
letcancelAnimationFrame: (WebAPI.DOMAPI.window,int)=>unitcancelIdleCallback
letcancelIdleCallback: (WebAPI.DOMAPI.window,int)=>unitclearInterval
letclearInterval: (WebAPI.DOMAPI.window,int)=>unitclearTimeout
Cancels the execution of a timeout created with setTimeout.
letclearTimeout: (WebAPI.DOMAPI.window,WebAPI.DOMAPI.timeoutId)=>unitconfirm
letconfirm: (WebAPI.DOMAPI.window, ~message:string=?)=>boolcreateImageBitmap
letcreateImageBitmap: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.htmlImageElement,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.htmlImageElement option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap10
letcreateImageBitmap10: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.htmlImageElement,~sx:int,~sy:int,~sw:int,~sh:int,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.htmlImageElement int int int int option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap11
letcreateImageBitmap11: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.svgImageElement,~sx:int,~sy:int,~sw:int,~sh:int,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.svgImageElement int int int int option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap12
letcreateImageBitmap12: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.htmlVideoElement,~sx:int,~sy:int,~sw:int,~sh:int,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.htmlVideoElement int int int int option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap13
letcreateImageBitmap13: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.htmlCanvasElement,~sx:int,~sy:int,~sw:int,~sh:int,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.htmlCanvasElement int int int int option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap14
letcreateImageBitmap14: (WebAPI.DOMAPI.window,~image:WebAPI.CanvasAPI.imageBitmap,~sx:int,~sy:int,~sw:int,~sh:int,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.CanvasAPI.imageBitmap int int int int option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap15
letcreateImageBitmap15: (WebAPI.DOMAPI.window,~image:WebAPI.CanvasAPI.offscreenCanvas,~sx:int,~sy:int,~sw:int,~sh:int,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.CanvasAPI.offscreenCanvas int int int int option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap16
letcreateImageBitmap16: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.videoFrame,~sx:int,~sy:int,~sw:int,~sh:int,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.videoFrame int int int int option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap17
letcreateImageBitmap17: (WebAPI.DOMAPI.window,~image:WebAPI.FileAPI.blob,~sx:int,~sy:int,~sw:int,~sh:int,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.FileAPI.blob int int int int option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap18
letcreateImageBitmap18: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.imageData,~sx:int,~sy:int,~sw:int,~sh:int,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.imageData int int int int option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap2
letcreateImageBitmap2: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.svgImageElement,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.svgImageElement option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap3
letcreateImageBitmap3: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.htmlVideoElement,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.htmlVideoElement option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap4
letcreateImageBitmap4: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.htmlCanvasElement,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.htmlCanvasElement option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap5
letcreateImageBitmap5: (WebAPI.DOMAPI.window,~image:WebAPI.CanvasAPI.imageBitmap,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.CanvasAPI.imageBitmap option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap6
letcreateImageBitmap6: (WebAPI.DOMAPI.window,~image:WebAPI.CanvasAPI.offscreenCanvas,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.CanvasAPI.offscreenCanvas option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap7
letcreateImageBitmap7: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.videoFrame,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.videoFrame option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap8
letcreateImageBitmap8: (WebAPI.DOMAPI.window,~image:WebAPI.FileAPI.blob,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.FileAPI.blob option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<WebAPI.CanvasAPI.imageBitmap >createImageBitmap9
letcreateImageBitmap9: (WebAPI.DOMAPI.window,~image:WebAPI.DOMAPI.imageData,~options:WebAPI.DOMAPI.imageBitmapOptions=?,)=>promise<WebAPI.CanvasAPI.imageBitmap>Parameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.imageData option<WebAPI.DOMAPI.imageBitmapOptions >Return type
promise<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
letdispatchEvent: (WebAPI.DOMAPI.window,WebAPI.EventAPI.event)=>boolfetch
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")letfetch: (WebAPI.DOMAPI.window,string,~init:WebAPI.FetchAPI.requestInit=?,)=>promise<WebAPI.FetchAPI.response>Parameters
WebAPI.DOMAPI.window string option<WebAPI.FetchAPI.requestInit >Return type
promise<WebAPI.FetchAPI.response >fetchWithRequest
fetchWithRequest(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)letfetchWithRequest: (WebAPI.DOMAPI.window,WebAPI.FetchAPI.request,~init:WebAPI.FetchAPI.requestInit=?,)=>promise<WebAPI.FetchAPI.response>Parameters
WebAPI.DOMAPI.windowWebAPI.FetchAPI.request option<WebAPI.FetchAPI.requestInit >Return type
promise<WebAPI.FetchAPI.response >focus
Moves the focus to the window's browsing context, if any.Read more on MDN
letfocus:WebAPI.DOMAPI.window=>unitgetComputedStyle
letgetComputedStyle: (WebAPI.DOMAPI.window,~elt:WebAPI.DOMAPI.element,~pseudoElt:string=?,)=>WebAPI.DOMAPI.cssStyleDeclarationParameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.element option< string >Return type
WebAPI.DOMAPI.cssStyleDeclarationgetSelection
letgetSelection:WebAPI.DOMAPI.window=>WebAPI.DOMAPI.selectionmatchMedia
letmatchMedia: (WebAPI.DOMAPI.window,string,)=>WebAPI.DOMAPI.mediaQueryListmoveBy
letmoveBy: (WebAPI.DOMAPI.window, ~x:int, ~y:int)=>unitmoveTo
letmoveTo: (WebAPI.DOMAPI.window, ~x:int, ~y:int)=>unitopen_
letopen_: (WebAPI.DOMAPI.window,~url:string=?,~target:string=?,~features:string=?,)=>WebAPI.DOMAPI.windowParameters
WebAPI.DOMAPI.window option< string > option< string > option< string >Return type
WebAPI.DOMAPI.windowpostMessage
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
letpostMessage: (WebAPI.DOMAPI.window,~message:JSON.t,~targetOrigin:string,~transfer:array<Dict.t<string>>=?,)=>unitParameters
WebAPI.DOMAPI.window Stdlib.JSON.t string option< array< Stdlib.Dict.t< string > > >Return type
unitpostMessage2
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
letpostMessage2: (WebAPI.DOMAPI.window,~message:JSON.t,~options:WebAPI.DOMAPI.windowPostMessageOptions=?,)=>unitParameters
WebAPI.DOMAPI.window Stdlib.JSON.t option<WebAPI.DOMAPI.windowPostMessageOptions >Return type
unitletprint:WebAPI.DOMAPI.window=>unitprompt
letprompt: (WebAPI.DOMAPI.window,~message:string=?,~default:string=?,)=>stringqueueMicrotask
letqueueMicrotask: (WebAPI.DOMAPI.window,WebAPI.DOMAPI.voidFunction)=>unitremoveEventListener
Removes the event listener in target's event listener list with the same type, callback, and options.Read more on MDN
letremoveEventListener: (WebAPI.DOMAPI.window,WebAPI.EventAPI.eventType,WebAPI.EventAPI.eventListener<'event>,~options:WebAPI.EventAPI.eventListenerOptions=?,)=>unitParameters
WebAPI.DOMAPI.windowWebAPI.EventAPI.eventTypeWebAPI.EventAPI.eventListener option<WebAPI.EventAPI.eventListenerOptions >Return type
unitremoveEventListener_useCapture
Removes the event listener in target's event listener list with the same type, callback, and options.Read more on MDN
letremoveEventListener_useCapture: (WebAPI.DOMAPI.window,WebAPI.EventAPI.eventType,WebAPI.EventAPI.eventListener<'event>,)=>unitParameters
WebAPI.DOMAPI.windowWebAPI.EventAPI.eventTypeWebAPI.EventAPI.eventListenerReturn type
unitreportError
letreportError: (WebAPI.DOMAPI.window,JSON.t)=>unitrequestAnimationFrame
letrequestAnimationFrame: (WebAPI.DOMAPI.window,WebAPI.DOMAPI.frameRequestCallback,)=>intrequestIdleCallback
letrequestIdleCallback: (WebAPI.DOMAPI.window,~callback:WebAPI.DOMAPI.idleRequestCallback,~options:WebAPI.DOMAPI.idleRequestOptions=?,)=>intParameters
WebAPI.DOMAPI.windowWebAPI.DOMAPI.idleRequestCallback option<WebAPI.DOMAPI.idleRequestOptions >Return type
intresizeBy
letresizeBy: (WebAPI.DOMAPI.window, ~x:int, ~y:int)=>unitresizeTo
letresizeTo: (WebAPI.DOMAPI.window, ~width:int, ~height:int)=>unitscroll
letscroll: (WebAPI.DOMAPI.window,~options:WebAPI.DOMAPI.scrollToOptions=?,)=>unitscroll2
letscroll2: (WebAPI.DOMAPI.window, ~x:float, ~y:float)=>unitscrollBy
letscrollBy: (WebAPI.DOMAPI.window,~options:WebAPI.DOMAPI.scrollToOptions=?,)=>unitscrollBy2
letscrollBy2: (WebAPI.DOMAPI.window, ~x:float, ~y:float)=>unitscrollTo
letscrollTo: (WebAPI.DOMAPI.window,~options:WebAPI.DOMAPI.scrollToOptions=?,)=>unitscrollTo2
letscrollTo2: (WebAPI.DOMAPI.window, ~x:float, ~y:float)=>unitsetInterval
letsetInterval: (WebAPI.DOMAPI.window,~handler:string,~timeout:int=?,)=>intsetInterval2
letsetInterval2: (WebAPI.DOMAPI.window,~handler:unit=>unit,~timeout:int=?,)=>intsetTimeout
Executes a function after a delay given in milliseconds expires.
letsetTimeout: (WebAPI.DOMAPI.window,~handler:unit=>unit,~timeout:int=?,)=>WebAPI.DOMAPI.timeoutIdstructuredClone
letstructuredClone: (WebAPI.DOMAPI.window,'t,~options:WebAPI.ChannelMessagingAPI.structuredSerializeOptions=?,)=>'t