非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

The non-standard HTMLCanvasElement.mozOpaque 特性为 布尔 反射 moz-opaque HTML attribute of the <canvas> element. It lets the canvas know whether or not translucency will be a factor. If the canvas knows there's no translucency, painting performance can be optimized.

This has been standardized as setting the alpha 选项到 false when creating a drawing context with HTMLCanvasElement.getContext() . Use of mozOpaque should be avoided. Firefox will stop supporting it in the future.

句法

var opaque = canvas.mozOpaque;
canvas.mozOpaque = true;
					

范例

Given this <canvas> 元素:

<canvas id="canvas" width="300" height="300" moz-opaque></canvas>
					

You can get or set the mozOpaque property. For example, you could conditionally set it to true if mimeType == 'image/jpeg' , or similar, to gain performance in your application when translucency is not needed.

var canvas = document.getElementById('canvas');
console.log(canvas.mozOpaque); // true
// deactivate it
canvas.mozOpaque = false;
					

规范

Not part of any standard.

浏览器兼容性

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
mozOpaque 非标 Chrome No Edge No Firefox 3 IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 4 Opera Android No Safari iOS No Samsung Internet Android No

图例

完整支持

完整支持

不支持

不支持

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

另请参阅

元数据

  • 最后修改: