svg文件中加载svg文件是出错(new ActiveXObject("Microsoft.XMLDOM")在svg文件中是不是不能用呀)
1----------------外层的svg文件如下:----------------------------------
<?xml version= "1.0 " encoding= "utf-8 "?>
<svg id= "svg " width= "800 " height= "600 " onload= "getContentInFile(); ">
<script>
<![CDATA[
function getContentInFile(){
var xmlDoc=new ActiveXObject( "Microsoft.XMLDOM ");
xmlDoc.async= "false ";
xmlDoc.load( "test.svg ");
nodes=xmlDoc.documentElement.childNodes;
alert(nodes);
}
]]>
</script>
<g id= "plat " >
<rect x= "0 " y= "60 " width= "720 " height= "450 " fill= "white "
stroke= "gray " stroke-width= "1 "/>
</g>
</svg>
2---------------------------test.svg文件如下-------------------------------
<?xml version= "1.0 " encoding= "utf-8 "?>
<svg width= "100% " height= "100% " xmlns:xlink= "http://www.w3.org/1999/xlink ">
<rect id= "backRect " x= "0 " y= "60 " width= "720 " height= "450 " fill= "white " stroke= "gray " stroke-width= "1 " />
<circle cx= "202 " cy= "312 " r= "43 " stroke= "red " stroke-width= "1 " fill= "blue " />
</svg>
[解决办法]
xmlDoc.async=false;