Web/API/HTMLCanvasElement/webglcontextcreationerror event

From Get docs


The webglcontextcreationerror event of the WebGL API is fired if the user agent is unable to create a WebGLRenderingContext context.

This event has a WebGLContextEvent.statusMessage property, which can contain a platform dependent string with more information about the failure.


Bubbles Yes
Cancelable Yes
Interface WebGLContextEvent
Event handler property none

Example

var canvas = document.getElementById('canvas');

canvas.addEventListener('webglcontextcreationerror', function(e) {
  console.log(e.statusMessage || 'Unknown error'); 
}, false);

var gl = canvas.getContext('webgl');
// logs statusMessage or "Unknown error" if unable to create WebGL context

Specifications

Specification Status Comment
WebGL 1.0The definition of 'webglcontextcreationerror' in that specification. Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
webglcontextcreationerror event Chrome

Full support 9

Edge

Full support 12

Firefox

Full support 49

IE

Full support 11

Opera

Full support 12

Safari

Full support 5.1

WebView Android

Full support Yes

Chrome Android

Full support 25

Firefox Android

Full support 49

Opera Android

Full support 12

Safari iOS

Full support 8

Samsung Internet Android

Full support 1.5

Legend

Full support  
Full support


See also