2008年8月29日

方向光标

代码效果:方向光标

代码如下:


<!--将以下代码加入HTML的<Body></Body>之间--><br /><br /><SCRIPT LANGUAGE="JavaScript"><br /><!-- Begin<br />var x, y, xold, yold, xdiff, ydiff;<br />var dir = Array();<br />dir[0] = "n-resize";<br />dir[1]="ne-resize";<br />dir[2]="e-resize";<br />dir[3]="se-resize";<br />dir[4] = "s-resize";<br />dir[5]="sw-resize";<br />dir[6]="w-resize";<br />dir[7]="nw-resize";<br />document.onmousemove = FindXY;<br />function display(direction) {<br />document.body.style.cursor = <br />dir[direction];<br />}<br />function FindXY(loc) {<br />x = (document.layers) ? loc.pageX : <br />event.clientX;<br />y = (document.layers) ? loc.pageY : <br />event.clientY;<br />xdiff = x - xold;<br />ydiff = y - yold<br />if ((xdiff < 2) && (ydiff < -2)) <br />display(0);<br />if ((xdiff < 2) && (ydiff > 2)) <br />display(4);<br />if ((xdiff > 2) && (ydiff < 2)) <br />display(2);<br />if ((xdiff < -2) && (ydiff < 2)) <br />display(6);<br />if ((xdiff > 2) && (ydiff > 2)) <br />display(3);<br />if ((xdiff > 2) && (ydiff < -2)) <br />display(1);<br />if ((xdiff < -2) && (ydiff > 2)) <br />display(5);<br />if ((xdiff < -2) && (ydiff < -2)) <br />display(7);<br />xold = x;<br />yold = y;<br />}<br />// End --><br /></script><br />


没有评论: