秋水就是秋水。 function replace(){ var arr=document.all("data"); var str=""; for(i=0;i<arr.length;i++)str+=(i*xMax/arr.length)+"pt,"+(yMax-arr[i].value)+"pt " polyline= document.createElement("v:polyline") polyline.points=str; doc.replaceChild(polyline,doc.children[1]) } 写的比我漂亮多了
points="50,0 120,50 150,100 170,175 250,200">
</v:polyline>
<head>
<title>testing VML</title>
</head>
<STYLE>
v\:* { BEHAVIOR: url(#default#VML) }
</STYLE>
<body>
<div>
<v:polyline id="mypolyline1" points="50,0 120,50 150,100 170,175 250,200"> </v:polyline>
</div>
<button onclick="test()">test</button>
<SCRIPT LANGUAGE="JavaScript">
<!--
function test()
{
poly = document.createElement("<v:polyline id=\"mypolyline2\" points=\"0,50 120,50 100,150 170,175 250,200\"> </v:polyline>");
mypolyline1.parentNode.insertBefore(poly.cloneNode(),mypolyline1)
mypolyline1.parentNode.removeChild(mypolyline1)
}
//-->
</SCRIPT></body>
</html>
mypolyline1.parentNode.insertBefore(poly.cloneNode(),mypolyline1)
先在mypolyline1前面插入以个新的polyline对象
mypolyline1.parentNode.removeChild(mypolyline1)
再把原来的polyline对象删掉。
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--></head><body><v:polyline id="mypolyline"
points="50,0 120,50 150,100 170,175 250,200" ONCLICK='changepoint()'>
</v:polyline>
<SCRIPT language=VBScript>
<!--Sub changepoint
mypolyline.points="50,0 120,50 150,100 170,175 250,100"
End Sub
-->
</SCRIPT><v:roundrect
fillcolor="green"
style="position:relative;top:1;left:1;width:50;height:50">
</v:roundrect><v:shape id=rect01
style="HEIGHT: 150px; LEFT: 20px; TOP: 20px; WIDTH: 150px"
coordsize = "200,200" fillcolor = "green"
strokecolor = "black" path = "m1,1l1,200,200,200,200,1xe">
<v:shadow on = "t" type = "single"
offset = "10pt,10pt"></v:shadow>
<v:fill type = "gradient" color2 = "yellow" angle = "45"></v:fill></v:shape>
<SCRIPT id=MYSCRIPT language=VBScript>
<!--
Sub ShapeChoice_OnChange
rect01.fill.color = ShapeChoice.Options(ShapeChoice.SelectedIndex).Text
End Sub
Sub ShapeChoice2_OnChange
rect01.fill.color2 = ShapeChoice2.Options(ShapeChoice2.SelectedIndex).Text
End SubSub ShadeChoice_OnChange
rect01.shadow.color = ShadeChoice.Options(ShadeChoice.SelectedIndex).Text
End SubSub Shade2Choice_OnChange
foo = Shade2Choice.Options(Shade2Choice.SelectedIndex).Text
foo2 = foo + "pt," + foo + "pt"
rect01.shadow.offset = foo2
End SubSub ShadeType_OnChange
rect01.fill.angle = ShadeType.Options(ShadeType.SelectedIndex).TextEnd Sub
-->
</SCRIPT>
<v:shapetype id="MyShape"
coordsize="21600,21600" adj="9931" path="m0@0c7200@2,14400@1,21600,0m0@5c7200@6,14400@6,21600@5e">
<v:formulas>
<v:f eqn="val #0"/>
<v:f eqn="prod #0 3 4"/>
<v:f eqn="prod #0 5 4"/>
<v:f eqn="prod #0 3 8"/>
<v:f eqn="prod #0 1 8"/>
<v:f eqn="sum 21600 0 @3"/>
<v:f eqn="sum @4 21600 0"/>
<v:f eqn="prod #0 1 2"/>
<v:f eqn="prod @5 1 2"/>
<v:f eqn="sum @7 @8 0"/>
<v:f eqn="prod #0 7 8"/>
<v:f eqn="prod @5 1 3"/>
<v:f eqn="sum @1 @2 0"/>
<v:f eqn="sum @12 @0 0"/>
<v:f eqn="prod @13 1 4"/>
<v:f eqn="sum @11 14400 @14"/>
</v:formulas>
<v:path textpathok="t" />
<v:textpath on="t" fitshape="t" xscale="t"/>
<v:handles>
<v:h position="topLeft,#0" yrange="0,12169"/>
</v:handles>
</v:shapetype><v:shape type="#MyShape" style='position:relative; top:10; left:5; width:261.6pt;height:71.45pt;'
adj="8717" fillcolor="red" strokeweight="1pt">
<v:fill method="linear sigma" focus="100%" type="gradient"/>
<v:shadow on="t" offset="3pt"/>
<v:textpath style='font-family:"Arial Black";v-text-kern:t' trim="t" fitpath="t" xscale="f" string="Hello World !"/>
</v:shape><v:shape type="#MyShape" style='position:relative; top:270; left:5; width:207pt;height:63pt;'
adj="8717" fillcolor="blue" strokeweight="2pt">
<v:fill method="linear sigma" focus="100%" type="gradient"/>
<v:shadow on="t" offset="3pt"/>
<v:textpath style='font-family:"Times New Roman";v-text-kern:t' trim="t" fitpath="t" xscale="f" string="VML"/>
</v:shape>
</body></html>
你给的代码不行阿,说缺少对象。
另外,微软msdn上说用
element.points="express"
function replace(){
var arr=document.all("data");
var str="";
for(i=0;i<arr.length;i++)str+=(i*xMax/arr.length)+"pt,"+(yMax-arr[i].value)+"pt "
polyline= document.createElement("v:polyline")
polyline.points=str;
doc.replaceChild(polyline,doc.children[1])
}
写的比我漂亮多了