90、在页面中画线

90、在页面中画线

脚本说明:

把如下代码加入<body>区域中

<script>

var winW= document.body.clientWidth;

var winH= document.body.clientHeight;

var MyStr="<object id=DDraw classid=\"clsid:369303C2-D7AC-11d0-89D5-00A0C90833E6\"";

MyStr+=" style=\"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>

 

Write a comment

Comments: 0