WEBGL_lose_context.restoreContext() method is part of the WebGL API and allows you to simulate restoring the context of a WebGLRenderingContext 对象。

句法

gl.getExtension('WEBGL_lose_context').restoreContext();
					

Errors thrown

  • INVALID_OPERATION if the context was not lost.

范例

With this method, you can simulate the webglcontextrestored event:

var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
canvas.addEventListener('webglcontextrestored', function(e) {
  console.log(e);
}, false);
gl.getExtension('WEBGL_lose_context').restoreContext();
					

规范

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

浏览器兼容性

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
restoreContext Chrome Yes Edge 17 Firefox 22
22
不支持 19 — 58 Prefixed
Prefixed Implemented with the vendor prefix: MOZ_
IE ? Opera Yes Safari ? WebView Android Yes Chrome Android Yes Firefox Android ? Opera Android Yes Safari iOS ? Samsung Internet Android Yes

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改: