<script language="JavaScript"> function HTMLDrawLine(){ divdraw.innerHTML=drawLine(150,250,450,300,"red")+drawLine(350,150,509,450,"black");} //绘制斜线的功能函数 function drawLine(x0,y0,x1,y1,color) { var linespan=""; if (y0 == y1){ //如为水平线 if (x0>x1) { var t=x0; x0=x1; x1=t; } //动态设置“ ”标记的样式属性 linespan="
"; }else if (x0==x1){ //如为垂直线 if (y0>y1){ var t=y0; y0=y1; y1=t; } linespan="
"; }else{ var lx=x1-x0; var ly=y1-y0; //通过直角公式,计算斜线的长度 var j=Math.sqrt(lx*lx+ly*ly); linespan=new Array(); for (var i=0;i 标记的坐标 var px=parseInt(x0+lx*p); var py=parseInt(y0+ly*p); //设置数组的相应元素内容 linespan[lines