javascript加载svg报错(若有xlink:href参数)
一下是加载svg文件的html文件
---------------------------------------------
<html>
<head>
<script
type= "text/javascript "
for= "window "
event= "onload ">
var xmlDoc=new ActiveXObject( "Microsoft.XMLDOM ")
xmlDoc.async= "false "
xmlDoc.load( "test.svg ")
nodes=xmlDoc.documentElement.childNodes
a1.innerText=nodes.item(0).nodeName
</script>
</head>
<body>
<div id= "a1 "> </div>
<br>
<div id= "a2 "> </div>
<br>
<div id= "a3 "> </div>
<br>
<div id= "a4 "> </div>
<br>
</body>
</html>
---------------------------------------
以下是svg文件(文件名test.svg)
-------------------------------------------
<?xml version= "1.0 " encoding= "utf-8 "?>
<svg width= "100% " height= "100% ">
<rect x= "0 " y= "60 " width= "720 " height= "450 " fill= "white " stroke= "gray " stroke-width= "1 " transform= "translate(-2,-39) " />
<circle cx= "205 " cy= "195 " r= "62 " stroke= "red " stroke-width= "1 " fill= "blue " />
<image x= "296 " y= "230 " width= "60 " height= "60 " xlink:href= "12.jpg "/>
</svg>
如果去掉 倒数第二行中的 xlink:href= "12.jpg ",就不报错!
怎么解决,谢谢呀
[解决办法]
<?xml version= "1.0 " encoding= "utf-8 "?>
<svg width= "100% " height= "100% ">
<rect x= "0 " y= "60 " width= "720 " height= "450 " fill= "white " stroke= "gray " stroke-width= "1 " transform= "translate(-2,-39) " />
<circle cx= "205 " cy= "195 " r= "62 " stroke= "red " stroke-width= "1 " fill= "blue " />
<image x= "296 " y= "230 " width= "60 " height= "60 " xlinkhref= "12.jpg "/>
</svg>