环境asp.net 文件名start.svg 代码如下:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg width='400' height='400' onload='loadXML()'
xmlns='http://www.w3.org/2000/svg'>
<script type="text/javascript">
<![CDATA[
function loadXML()
{
var xmlDoc;
if(window.ActiveXObject)
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
else if(document.implementation && document.implementation.createDocument)
xmlDoc = document.implementation.createDocument("","Table",null);
xmlDoc.async=false;
xmlDoc.load("Test.xml");
node = xmlDoc.getElementsByTagName('Table');
var i=node.Length;
for(var j=0;j <i;j++)
{
var shape = document.createElement('rect');
shape.setAttribute('x', 'parseInt(Math.random()*(830-20+1)+20)');
shape.setAttribute('y', 'parseInt(Math.random()*(370-20+1)+20)');
shape.setAttribute('width','70');
shape.setAttribute('height','40');
shape.setAttribute('style', 'fill: #eeeeee');
shape.getStyle().setProperty('stroke','red');
shape.getStyle().setProperty('stroke-width','1');
document.getDocumentElement().insertBefore(shape,document.getDocumentElement().firstChild);
}
}
]]>
</script>
</svg>
错误提示如下:wrong number of parameters,3 expected line:8,column:11
Default.aspx中内嵌了 <embed src="start.svg" type="image/svg+xml"
pluginspage="http://www.adobe.com/svg/viewer/install/"
style="border: 1px solid black; padding:5px; width: 850px; height: 370px;"/>
我用svg事例代码放到start.svg文件中,Default.aspx能正常显示svg效果。用上文代码则出现script error。错误提示即上文提到的错误提示
请教各位大侠,指点一二。不胜感激!