在 HTML 页面中添加 SVG 图形,通常使用 object 标签将其包裹,如下所示:
<object id="svgid" data="mysvg.svg" type="image/svg+xml"
wmode="transparent" width="100" height="100">
this browser is not able to show SVG: <a linkindex="3"
href="http://getfirefox.com">http://getfirefox.com</a>
is free and does it!
If you use Internet Explorer, you can also get a plugin:
<a linkindex="4" href="http://www.adobe.com/svg/viewer/install/main.html">
http://www.adobe.com/svg/viewer/install/main.html</a>
</object>
如果在对象标签中不使用宽度和高度属性,则svg将以全尺寸显示。通常,我从Open Graphics Library获取svg文件进行测试。是否有通过JavaScript获取svg大小的方法?或者我应该只查看svg xml文件,从顶部的svg标签找出大小?
obj.contentDocument
未定义。 - David Wolever