文字環繞鼠標跟蹤

- 中國WEB開發者網絡 (http://www.webasp.net)
-- 網頁特效 (http://www.webasp.net/javascript/)
--- 文字環繞鼠標跟蹤 (http://www.webasp.net/javascript/1/280.htm)
-- 發佈日期: 2004-07-13
<!-- 網頁特效代碼由[中國WEB開發者網絡:http://www.ChinaWebDev.com]提供! -->
<!-- 要實現此效果需要 1 個步驟: -->

<!-- 第 1 步: -->
<!-- 把下面的代碼加到<BODY></BODY>區域中: -->

<script language="JavaScript">
<!--
var mouse=new Object()
mouse.msg="歡迎訪問webasp.net站點"
mouse.x=0
mouse.y=0
mouse.speed=Math.PI/180 // 1 degree
mouse.radius=50
mouse.ms=new Array()
if(document.layers){
document.captureEvents(Event.MOUSEMOVE)
for(i=0;i<=mouse.msg.length;i++)document.write("<layer name='mousetext"+i+"'>"+mouse.msg.charAt(i)+"</layer>")
}else
for(i=0;i<=mouse.msg.length;i++)document.write("<span id='mousetext"+i+"' class='tacoscript'>"+mouse.msg.charAt(i)+"</span>")
for(i=0;i<=mouse.msg.length;i++){
mouse.ms[i]=document.getElementById?document.getElementById("mousetext"+i).style:document.all?document.all["mousetext"+i].style:document.layers["mousetext"+i]
mouse.ms[i].deg=Math.PI*2/mouse.msg.length*i}
document.onmousemove=function m(e){
if(!e)e=event
mouse.x=document.all?document.body.scrollLeft+e.clientX:e.pageX
mouse.y=document.all?document.body.scrollTop+e.clientY:e.pageY
run()}
function run(){
for(i=mouse.ms.length-1;i>=0;i--){
mouse.ms[i].deg+=mouse.speed
mouse.ms[i].left=mouse.x-Math.sin(mouse.ms[i].deg)*mouse.radius
mouse.ms[i].top=mouse.y+Math.cos(mouse.ms[i].deg)*mouse.radius}}
setInterval(run,100)
//-->
</script>
<style type="text/css">
<!--
.tacoscript {font-size:10pt; color=CC33FF; POSITION: absolute;VISIBILITY: visible}
-->
</style>


webasp.net