HTML页面加载SVG
<embed name="SVG_PowerSystemGraph" width="780px" height="350px" src="../SVGFile/PowerSystemGraph.svg" type="image/svg+xml"></embed>
<script type="text/javascript">
document.onreadystatechange = function()
{
if(document.readyState == "complete")
{
Windown_LoadSVG("<%=CurrentMachNo %>", <%=PowerSystemGraphRefurbishCyc %>);
}
}
window.onunload = SVGDisponse;
</script>
乱码解决方法
1、 设置SVG文档编码格式:encoding="utf-8";
2、 SVG文件的编码方式指定为utf-8,方法是用EditPlus打开SVG文件,文件->另存为 编码选择为utf-8即可以了;
基本的svgDOM树:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300">
<g >Click on rectangle to change it's color.</text>
</g>
</svg>
检查,并删除属性值
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="300" height="300">
<script type="text/ecmascript">
<![CDATA[
function removeFill(evt)
{
//通过获得元素,
var element = evt.target;
if (element.hasAttributeNS(null,"fill"))
{
element.removeAttributeNS(null,"fill");
}
else
{
alert("This element doesn't have a fill attribute.");
}
}
]]>
</script>
<g >of each line</tspan>
</text>
</g>
</svg>