HTML不支持曲线,JS根据不可能,只有DHTML可以做到,原理在下面说
方法1:
<object classid="clsid:3A2B370C-BA0A-11D1-B137-0000F8753F5D"
id=mschart1 style="HEIGHT: 310px;
WIDTH: 440px"
codebase="mschart.cab">
参考http://www.csdn.net/vote/result1.asp?poll_id=129 源代码
方法2:利用Dhmtl,因为标准HTML没有曲线元素,原理就是利用DIV层的方式,重叠很多层,看起来想曲线,其实是很多离散的点,如果用这种方式需要自己去下载JS的图形库
方法3:利用VML,美洲豹有个很完整的教程,楼主可以去下载
http://www.9seek.com/c19.aspx
这里代码非常多
方法4:还是利用Activex控件的做法,参考代码如下
<HTML>
<HEAD>
<TITLE>画线-www.51windows.Net</TITLE>
<meta http-equiv="Content-Type"
content="text/html;
charset=gb2312">
<META NAME="Author"
CONTENT="www.Redidea.net">
</HEAD>
<body bgcolor=#CCCCCC>
<script>
var winW= 480;
var winH= 360;
var MyStr="<object id=DDraw classid=/"clsid:369303C2-D7AC-11d0-89D5-00A0C90833E6/"";
MyStr+="
style=/"background:#FFFFFF;position:absolute;left:0;top:0;width:";
MyStr+=winW;
MyStr+=";height:";
MyStr+=winH;
MyStr+="/"></object>";
document.write(MyStr);
</script>
<script language=JavaScript>
var IsClick=0;
var MouseX0=0;
var MouseY0=0;
function MyDraw(){
if (IsClick) {
if ((MouseX0==0)&&(MouseY0==0)){
MouseX0=event.clientX-winW/2;
MouseY0=event.clientY-winH/2;
}
MouseX=event.clientX-winW/2;
MouseY=event.clientY-winH/2;
var Canvas=DDraw.DrawSurface;
var Lib=DDraw.Library;
Canvas.FillColor(Lib.red);
Canvas.Line(MouseX0,MouseY0,MouseX,MouseY);
DDraw.DrawSurface=Canvas;
MouseX0=MouseX;
MouseY0=MouseY;
}
}
function MyClick(){
IsClick=!IsClick;
MouseX0=event.clientX-winW/2;
MouseY0=event.clientY-winH/2;
}
document.onclick=MyClick;
document.onmousemove=MyDraw;
</script>
<div style="position:absolute;left:0;top:380;">点一下鼠标,然后松开,移动鼠标,就可以画了,再点一下,就结束了..
<br>来自:www.Redidea.net</div>
</body>
------------------------------------
以上所有方法都是服务器端主动