This is an experimental technology
Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.
The OffscreenCanvas()
constructor returns a newly instantiated OffscreenCanvas
object.
SyntaxEdit
new OffscreenCanvas(width, height);
Parameters
width
- The height of the offscreen canvas.
height
- The width of the offscreen canvas.
ExamplesEdit
Creating a new offscreen canvas and initializing a WebGL context on it:
var offscreen = new OffscreenCanvas(256, 256);
var gl = offscreen.getContext("webgl");
SpecificationsEdit
Currently drafted as a proposal: OffscreenCanvas.
Browser compatibilityEdit
[1] This feature is behind a feature preference setting. In about:config, set gfx.offscreencanvas.enabled
to true
.
See alsoEdit
OffscreenCanvas
, the interface this constructor belongs to.