マウスを回りながら追いかける画像(Math.cos, Math.sin)
<html> <head> <title>マウスを回りながら追いかける画像</title> <script language="JavaScript"> <!-- t = 0; function move(){ t = t + 0.05; img1.style.pixelLeft = event.x + 50 * Math.cos(t); img1.style.pixelTop = event.y + 50 * Math.sin(t); } //--> </script> </head> <body onMousemove="move()"> <img src="../../sample/img/img2.gif" ID="img1" STYLE="position:absolute;top:0;left:0"> </body> </html>
〔 実行する 〕