getContext method
Returns an object that provides methods and properties for drawing and manipulating images and graphics on a canvas element in a document. A context object includes information about colors, line widths, fonts, and other graphic parameters that can be drawn on a canvas.
![]() ![]() |
Syntax
CanvasRenderingContext2D retVal = object.getContext(contextId, contextAttribute);
Parameters
- contextId [in]
-
Type: string
The identifier (ID) of the type of canvas to create.
Internet Explorer 9 and Internet Explorer 10 support only a 2-D context using
canvas.getContext("2d");IE11 also supports 3-D or WebGL context using
canvas.getContext("experimental-webgl"); - contextAttribute [in, optional]
-
IE11 supports an optional set of WebGLContextAttributes for WebGL content. See getContextAttributes for more info.
Standards information
- The canvas element, Section 4.8.11
Remarks
The IHTMLCanvasElement::getContext method returns NULL if the contextId value is not supported.
See also

