WEBGL_lose_context.loseContext() method is part of the WebGL API and allows you to simulate losing the context of a WebGLRenderingContext 上下文。

It triggers the steps described in the WebGL specification for handling context lost. The context will remain lost until WEBGL_lose_context.restoreContext() 被调用。

句法

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

范例

With this method, you can simulate the webglcontextlost event:

var canvas = document.getElementById('canvas');
var gl = canvas.getContext('webgl');
canvas.addEventListener('webglcontextlost', function(e) {
  console.log(e);
}, false);
gl.getExtension('WEBGL_lose_context').loseContext();
// WebGLContextEvent event with type "webglcontextlost" is logged.
					

规范

规范 状态 注释
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
loseContext 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

图例

完整支持

完整支持

兼容性未知 ?

兼容性未知

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

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

另请参阅

元数据

  • 最后修改: