How do I know if my browser supports SVG 2.0?

2019-03-24 12:20发布

How do I know if my browser supports SVG 2.0?

(Apart from trying a feature that is supposed to work in SVG2 and realizing it's not working or that it works ...?)

标签: svg
3条回答
叛逆
2楼-- · 2019-03-24 12:25

From what I understand SVG 2.0 is still a work in progress with no full browser implementation.

For the more elusive features of SVG that may not be implemented by all browser you can check CanIUse to see if the feature is supported.

查看更多
做个烂人
3楼-- · 2019-03-24 12:34

Asking if a browser supports SVG 2 is like asking if a browser supports HTML5. It seems like a totally reasonable question, but it doesn't work like that.

The best we can do is test if a browser supports a feature, rather than a version of spec. As you can see from the SVG 2 Support in Mozilla page, it's a mixed bag.

查看更多
ら.Afraid
4楼-- · 2019-03-24 12:43

According to SVG 2.0 specification it may be something like

document.implementation.hasFeature("http://www.w3.org/TR/SVG2/feature#GraphicsAttribute", 2.0)

SVG 1.1 support you can check with hasFeature call

document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#SVG", 1.1)

EDIT: hasFeature is deprecated and removed from Web standards. It will return always true on modern browsers (DOM Spec).

查看更多
登录 后发表回答