A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen below:

HTMLCanvasElement: transferControlToOffscreen() method - Web APIs

HTMLCanvasElement: transferControlToOffscreen() method

Baseline 2023

Newly available

The HTMLCanvasElement.transferControlToOffscreen() method transfers control to an OffscreenCanvas object, either on the main thread or on a worker.

Syntax
transferControlToOffscreen()
Parameters

None.

Return value

An OffscreenCanvas object.

Exceptions
InvalidStateError DOMException

Throws if:

Examples

The following example shows how to transfer control to an OffscreenCanvas object on the main thread.

const htmlCanvas = document.createElement("canvas");
const offscreen = htmlCanvas.transferControlToOffscreen();
const gl = offscreen.getContext("webgl");

// Some drawing using the gl context…

The following example shows how to transfer control to an OffscreenCanvas object on a worker.

const offscreen = document.querySelector("canvas").transferControlToOffscreen();
const worker = new Worker("my-worker-url.js");
worker.postMessage({ canvas: offscreen }, [offscreen]);
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4