最近需求要在页面上画直线,下面有两个方法
第一种:这是通过点来生成一条直线
<html>
<head>
<script type="text/javascript">
/************* 画点 **************
x,y 点所在的屏幕坐标(像素)
color 颜色(字符串值)
size 大小(像素)
**********************************/
function drawDot(x,y,color,size){
document.write( " <table border= '0 ' cellspacing=0 cellpadding=0> <tr> <td style= 'position: absolute; left: "+(x)+ "; top: "+(y)+ ";background-color: "+color+ " ' width= "+size+ " height= "+size+ "> </td> </tr> </table> ")
}
/************* 画直线 **************
x1,y1 起点所在的屏幕坐标(像素)
x2,y2