當前位置:開發者網絡 >> 網頁特效 >> 鼠標事件 >> 內容
精彩推薦
分類最新特效
分類熱點特效
   
文字環繞鼠標跟蹤
日期: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>