对于SVG滤镜功能检测支持 [英] Feature detecting support for svg filters
本文介绍了对于SVG滤镜功能检测支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要配备检测浏览器是否支持SVG滤镜(feGaussianBlur,要具体)。我怎么会去测试这个? Safari浏览器,不支持的过滤器,自动忽略过滤器。
I need to feature detect whether a browser supports svg filters (feGaussianBlur, to be specific). How would I go about testing for this? Safari, which doesn't support the filter, silently ignores the filter.
推荐答案
您很可能还查看接口可用的枚举,例如:
You could probably also check the enums available on the interfaces, e.g:
var supportsfilter = typeof SVGFEColorMatrixElement !== undefined &&
SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_SATURATE==2;
这样你就不需要建立新的元素,如 http://stackoverflow.com/a/9767059/109374 。我没有测试,看看这是否将按预期在Safari。
That way you won't have to construct new elements, as in http://stackoverflow.com/a/9767059/109374. I've not tested to see whether this works as expected in Safari.
更新:
提交Modernizr的修补程序: https://github.com/Modernizr/Modernizr/pull/531
这篇关于对于SVG滤镜功能检测支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文