随鼠标的闪烁小星星

把如下代码加入

 1<body>区域中   
 2<script language="JavaScript">   
 3<!--   
 4colours=new Array('#ffffff','#ff0000','#00ff00','#ffffff','#ff00ff','#ffa500','#fff000','#0000ff','#ffffff') 
 5
 6y = 0;   
 7x = 0;   
 8n6=(document.getElementById&&!document.all);   
 9ns=(document.layers);   
10ie=(document.all);   
11d=(ns||ie)?'document.':'document.getElementById("';   
12a=(ns||n6)?'':'all.';   
13n6r=(n6)?'")':'';   
14s=(ns)?'':'.style';   
15n=(n6)?9:10;   
16if (ns){   
17for (i = 0; i < n; i++)   
18document.write('<layer name="dots'+i+'" top=0 left=0 width='+i/2+' height='+i/2+' bgcolor=#ff0000></layer>');   
19}   
20if (ie)   
21document.write('<div id="con" style="position:absolute;top:0px;left:0px"><div style="position:relative">');   
22if (ie||n6){   
23for (i = 0; i < n; i++)   
24document.write('<div id="dots'+i+'" style="position:absolute;top:0px;left:0px;width:'+i/2+'px;height:'+i/2+'px;background:#ff0000;font-size:'+i/2+'"></div>');   
25}   
26if (ie)   
27document.write('</div></div>'); 
28
29  
30(ns||n6)?window.captureEvents(Event.MOUSEMOVE):0;   
31function Mouse(evnt){   
32y = (ns||n6)?evnt.pageY+4 - window.pageYOffset:event.y+4;   
33x = (ns||n6)?evnt.pageX+1:event.x+1;   
34}   
35(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse; 
36
37function animate(){   
38h=(ns||n6)?window.innerHeight:document.body.clientHeight;   
39w=(ns||n6)?window.innerWidth:document.body.clientWidth; 
40
41o=(ns||n6)?window.pageYOffset:0;   
42if (ie)con.style.top=document.body.scrollTop;   
43for (i = 0; i < n; i++){   
44var temp1 = eval(d+a+"dots"+i+n6r+s);   
45var randcolours = Math.floor(Math.random()*colours.length);   
46(ns)?temp1.bgColor = colours[randcolours]:temp1.background = colours[randcolours];   
47if (i < n-1){   
48var temp2 = eval(d+a+"dots"+(i+1)+n6r+s);   
49temp1.top = parseInt(temp2.top);   
50temp1.left = parseInt(temp2.left);   
51}   
52else{   
53temp1.top = y+o;   
54temp1.left = x;   
55}   
56if ((y < h/10) || (y > h-h/10) || (x < w/10) || (x > w-w/10)){   
57var temp3 = eval(d+a+"dots"+0+n6r+s);   
58temp3.top = (y-25)+Math.random()*50;   
59temp3.left = (x-25)+Math.random()*50;   
60temp2.top = parseInt(temp3.top)+o;   
61temp2.left = parseInt(temp3.left);   
62}   
63}   
64setTimeout("animate()",30);   
65}   
66animate();   
67// -->   
68</script></body>
Published At
Categories with 网页设计
Tagged with
comments powered by Disqus