IE9 importing inline SVG <image> elements broken

五迷三道 提交于 2019-12-07 12:43:26

问题


I am using this method to import an SVG doc into a page, and it works pretty well, but in IE9, none of the <image> tags work after the import (they show up as broken images, even though their xlink:href attribute is correct). Why does this happen, and is there any way around it? Here's a simple test page. It works fine in Chrome, FF, etc, but not in IE9.


回答1:


The js implementation of importNode provided in this answer doesn't properly set namespaced attributes, it should use setAttributeNS to set xlink:href correctly. This other implementation of importNode seems to handle that, have you tried using that one instead?




回答2:


Apparently if I drop the xlink: and just use href, if fixes the problem in IE9, but breaks it in Chrome, etc. Weird! If anyone knows why, I'd be happy to accept your answer. See test 2.

Adding href, in addition to xlink:href fixes the issue everywhere.



来源:https://stackoverflow.com/questions/14593520/ie9-importing-inline-svg-image-elements-broken

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!