如何以编程方式查找我的浏览器是否支持HTML5混合模式(http://www.w3.org/TR/compositing-1/#mix-blend-mode)?
我的代码结构如下
var canvas = document.getElementById("Canvas");
var context = canvas.getContext("2d");
context.fillStyle = "#fff";
context.fillRect(0, 0, canvas.width, canvas.height);
context.globalCompositeOperation = "source-over"
context.globalCompositeOperation = "soft-light";
if (context.globalCompositeOperation){
//browser supports
alert('true');
}
else {
// browser doesn't support
alert('false');
}
但这似乎不正确。即使在IE中,它也会警告“ true”。(http://caniuse.com/#search=blend表示IE中不支持混合模式)
你应该用
context.globalCompositeOperation = blendMode;
if (context.globalCompositeOperation !== blendMode){
// not supported mode
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句