VML铅笔画
<HTML xmlns:v>
<HEAD>
<META http-equiv='Content-Type' content='text/html;charset=gb2312'>
<Meta name='Gemeratpr' content='网络程序员伴侣(Lshdic)2005'>
<TITLE>VML最简实现铅笔绘图功能</TITLE>
<STYLE>
v\:*{behavior:url(#default#VML);}
</STYLE>
</HEAD>
<body bgcolor=black>
<div id=div1 style="background-color:white;width:400;height:400"></div><br><input type=button value="清空" onclick="div1.innerHTML=''">
<script>
var xx=0,yy=0,oldvalue="",poly1,zz=1
function div1.onmousedown(){
if(event.button==1){
div1.setCapture()
color1="red"
size1=1
xx=event.x;yy=event.y;zz+=1
poly1=div1.appendChild(document.createElement("<v:shape filled=false path='m0,0 l0,0' style='position:absolute;z-index:"+zz+";left:"+xx+";top:"+yy+";width:100;height:100' strokecolor='"+color1+"' strokeweight='"+size1+"' coordsize='100,100'/>"))
oldvalue=poly1.path.value.replace("e","")
}}
function div1.onmousemove(){
if(event.button==1){
if(event.srcElement.tagName=="BODY"){div1.releaseCapture();return false}
oldvalue+=","+(event.x-xx)+","+(event.y-yy);poly1.path.value=oldvalue
poly1.path.value=poly1.path.value.replace(",0,",",").replace(",0 e","e")
}}
function div1.onmouseup(){
div1.releaseCapture();
}
</script>