虫虫技术在线--技术决定出路

当前位置: 首页 > 网络 > 建站运营 > 网页设计 >

鼠标跟随特效的源代码

时间:2010-08-29 09:46来源:网页特效观止 作者:虫虫编辑 点击:
鼠标跟随特效的源代码: 需要下载的文件: Select.rar html xmlns:v = urn:schemas-microsoft-com:vml STYLE body{margin:0px;cursor:url(http://www.jscode.cn/jscode/images/Select.cur)} v\:*{Behavior:url(#default#VML)} / STYLE scr

鼠标跟随特效的源代码:

需要下载的文件:

Select.rar

  1. <html xmlns:v="urn:schemas-microsoft-com:vml"> 
  2. <STYLE> 
  3. body{margin:0px;cursor:url(http://www.jscode.cn/jscode/images/Select.cur)}  
  4. v\:* { Behavior: url(#default#VML) }  
  5. </STYLE> 
  6.  
  7.     <script> 
  8.      var trace="" 
  9.      var vP  
  10.      var r=0 
  11.      var vS  
  12.      var p=new Object()  
  13.      var lineColor=[[255,0,0],[255,0,255]]  
  14.      p.x=0;p.y=0 
  15.      function init(){  
  16.          document.body.onmousedown=function(){  
  17.            if (event.button==1 || event.button==4){  
  18.             if (event.button==1) vP=document.createElement("v:PolyLine"); else vP=document.createElement("v:line");  
  19.            }  
  20.            vS=document.createElement("v:stroke")  
  21.            vP.filled="false" 
  22.            vP.appendChild(vS)  
  23.            document.body.appendChild(vP)  
  24.            trace="";  
  25.            if (event.button==4) vP.from.value=event.clientX + "," + event.clientY;  
  26.          }  
  27.            
  28.          document.body.onmousemove=function(){  
  29.            if (event.button==1){  
  30.            pos=event.clientX + "," + event.clientY + " ";  
  31.            trace+=pos  
  32.            vS.color="rgb(255,0,0)" 
  33.            vP.points.value=trace 
  34.           }  
  35.           if  (event.button==4) {  
  36.            vP.to.value=event.clientX + "," + event.clientY;  
  37.           }  
  38.             
  39.           rImg.style.left=event.clientX-20;  
  40.           rImg.style.top=event.clientY-20;  
  41.             
  42.           var cX = p.x-event.clientX;  
  43.           var cY = p.y-event.clientY;  
  44.           if (cX || cY) {  
  45.                     status ="cX:"+cX+" -cY:"+cY  
  46.               rotationImg(180-parseInt(Math.atan2(cY,cX)*180/Math.PI,10));  
  47.           }    
  48.               p.x=event.clientX;  
  49.               p.y=event.clientY;       
  50.          }  
  51.        
  52.          document.body.onmouseup=function(){  
  53.                vS.EndArrow="Block" 
  54.           }  
  55.          document.onselectstart=function(){return false}  
  56.      }  
  57.        
  58.      function rotationImg(flag){  
  59.        window.status=r + " to " + flag;  
  60.        var step=3;  
  61.          while(r-flag>180) flag+=360  
  62.          while(flag-r>180) flag-=360 
  63.          r += (flag-r)/step  
  64.      rImg.style.rotation=90-r;  
  65.     }  
  66.     </script> 
  67. <body onload="init()"> 
  68. <v:image id="rImg" src="http://www.jscode.cn/jscode/images/mouse.gif" style="position:absolute;top:0;left:0;width:37;height:37;0" > 
  69.  <v:Stroke dashstyle="Solid"/> 
  70. </v:image> 
  71. </body> 

 

(责任编辑:admin)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
推荐内容