SVG中ForeignObject的特征检测 [英] Feature detection of foreignObject in SVG

查看:79
本文介绍了SVG中ForeignObject的特征检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在SVG中使用foreignObject元素,但是IE9不支持该元素.我正在寻找一种检测此功能的方法. Modernizr未检测到此功能,似乎我无法像对矩形(createSVGRect)一样使用createSVGForeignObject(在SVGSVGElement上不可用).

I am using the foreignObject element in SVG, however IE9 does not support this element. I am looking at a way the detect this feature. Modernizr does not detect this feature and it seems I can not use createSVGForeignObject (not available on SVGSVGElement) like they do for rectangle (createSVGRect).

谢谢!

推荐答案

如果您要使用foreignObject,这应该可以工作,因为它集成了html内容...

This should work if you want to use foreignObject because it integrates html content...

<switch>
  <g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility" requiredExtensions="http://www.w3.org/1999/xhtml">
    <foreignObject >
    </foreignObject>
  </g>
  <text font-size="10" font-family="Verdana">
     No foreignObject
  </text>
</switch>

requiredExtensions部分建议用于w3c 这是他们的回应. Firefox确实实现了这一点,但是我还没有测试其他任何东西.正如Erik所建议的那样,您也许可以只使用requiredFeatures属性.

The requiredExtensions part proposed to w3c and this was their response. Firefox does implement this, but I havent tested anything else though. You may be able to get away with just the requiredFeatures attribute as Erik suggests.

如果您要使用javascript测试,请尝试

If you want to test in javascript try

var supported = document.implementation.hasFeature("http://w3.org/TR/SVG11/feature#Extensibility", "1.1"); –  

这篇关于SVG中ForeignObject的特征检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆