[原]JS动态创建VML
//画直线,加入到group1
function createLine(id,startArrow,endArrow){
var le = document .createElement( "<v:line><v:line>" );
var ske = document.createElement("<v:stroke/>");
if(startArrow != '')
ske.StartArrow="classic";
if(endArrow != '')
ske.EndArrow="classic";
le.appendChild(ske);
le.id = id;
group1.insertBefore(le);
}
//画圆角矩形,有3D效果,加入到group1
function createRect(id,text,left,top,isEnd){
var rectColor="#61f2fe";
if(isEnd=='t')rectColor="red";
var strElement='<v:roundrect fillcolor="'+rectColor+'" id='+id+' style="POSITION:absolute;Z-INDEX:1;left:'+left+';width:70;top:'+top+';height:70" strokecolor="black" strokeweight="1px" onmousedown="down(this)" onmousemove="move(this)" onmouseup="up(this)" title = "' + text + '"></v:roundrect>';
var newRect = document.createElement(strElement);
newRect.innerHTML = "<v:TextBox inset='5pt,5pt,5pt,5pt' style='font-size:10.2pt;'>"+text+"</v:TextBox>";
var extru = document.createElement('<v:Extrusion></v:Extrusion>');
extru.on="t";
extru.foredepth="0";
extru.backdepth="4pt";
extru.color=rectColor;
extru.rotationangle="0,0";
newRect.appendChild(extru);
group1.insertBefore(newRect);
}
function createLine(id,startArrow,endArrow){
var le = document .createElement( "<v:line><v:line>" );
var ske = document.createElement("<v:stroke/>");
if(startArrow != '')
ske.StartArrow="classic";
if(endArrow != '')
ske.EndArrow="classic";
le.appendChild(ske);
le.id = id;
group1.insertBefore(le);
}
//画圆角矩形,有3D效果,加入到group1
function createRect(id,text,left,top,isEnd){
var rectColor="#61f2fe";
if(isEnd=='t')rectColor="red";
var strElement='<v:roundrect fillcolor="'+rectColor+'" id='+id+' style="POSITION:absolute;Z-INDEX:1;left:'+left+';width:70;top:'+top+';height:70" strokecolor="black" strokeweight="1px" onmousedown="down(this)" onmousemove="move(this)" onmouseup="up(this)" title = "' + text + '"></v:roundrect>';
var newRect = document.createElement(strElement);
newRect.innerHTML = "<v:TextBox inset='5pt,5pt,5pt,5pt' style='font-size:10.2pt;'>"+text+"</v:TextBox>";
var extru = document.createElement('<v:Extrusion></v:Extrusion>');
extru.on="t";
extru.foredepth="0";
extru.backdepth="4pt";
extru.color=rectColor;
extru.rotationangle="0,0";
newRect.appendChild(extru);
group1.insertBefore(newRect);
}