Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

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.

The canvas element, Section 4.8.11Internet Explorer 9


CanvasRenderingContext2D retVal = object.getContext(contextId, contextAttribute);


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 IHTMLCanvasElement::getContext method returns NULL if the contextId value is not supported.

Note  A canvas object only supports one context. Additional calls to IHTMLCanvasElement::getContext this object return the same context.

Note  If you are developing on an intranet and have rendering issues for HTML5, you can add a "meta http-equiv-'X-UA-Compatible' content= edge" to the <head> block of a webpage to force Windows Internet Explorer to use the latest standards. You shouldn't use this meta-tag for production webpages. For more information about document compatibility, see Defining Document Compatibility.

See also




Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.