webglcontextcreationerror event of the WebGL API is fired if the user agent is unable to create a WebGLRenderingContext 上下文。

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

冒泡 Yes
可取消 Yes
接口 WebGLContextEvent
事件处理程序特性 none

范例

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
					

规范

规范 状态 注释
WebGL 1.0
The definition of 'webglcontextcreationerror' in that specification.
推荐 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
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 9 Edge 12 Firefox 49 IE 11 Opera 12 Safari 5.1 WebView Android Yes Chrome Android 25 Firefox Android 49 Opera Android 12 Safari iOS 8 Samsung Internet Android 1.5

图例

完整支持

完整支持

另请参阅

元数据

  • 最后修改: