js跟随鼠标冒水泡效果
1<body bgcolor="#ffffff">
2<SCRIPT LANGUAGE="JavaScript">
3<!-- Begin
4Image0 = new Image();
5Image0.src = "xfile.php?xname=686QF01&fname=/images_bbs/lovely/165.gif";
6Amount = 20;
7Ymouse = -50;
8Xmouse = -50;
9Ypos = new Array();
10Xpos = new Array();
11Speed = new Array();
12rate = new Array();
13grow = new Array();
14Step = new Array();
15Cstep = new Array();
16nsSize = new Array();
17ns = (document.layers)?1:0;
18(document.layers)?window.captureEvents(Event.MOUSEMOVE):0;
19function Mouse(evnt) {
20Ymouse=(document.layers)?evnt.pageY-20:event.y-20;
21Xmouse=(document.layers)?evnt.pageX:event.x;
22}
23(document.layers)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
24for (i = 0; i < Amount; i++) {
25Ypos[i] = Ymouse;
26Xpos[i] = Xmouse;
27Speed[i] = Math.random()*4+1;
28Cstep[i] = 0;
29Step[i] = Math.random()*0.1+0.05;
30grow[i] = 8;
31nsSize[i] = Math.random()*15+5;
32rate[i] = Math.random()*0.5+0.1;
33}
34if (ns) {
35for (i = 0; i < Amount; i++) {
36document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+Image0.src+" name='N' width="+nsSize[i]+" height="+nsSize[i]+"></LAYER>");
37}
38}
39else {
40document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
41for (i = 0; i < Amount; i++) {
42document.write('<img id="si" src="'+Image0.src+'" style="position:absolute;top:0px;left:0px;filter:alpha(opacity=90)">');
43}
44document.write('</div></div>');
45}
46function MouseBubbles() {
47var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop;
48var wscrll = (document.layers)?window.pageXOffset:document.body.scrollLeft;
49for (i = 0; i < Amount; i++){
50sy = Speed[i] * Math.sin(270 * Math.PI / 180);
51sx = Speed[i] * Math.cos(Cstep[i] * 4);
52Ypos[i] += sy;
53Xpos[i] += sx;
54if (Ypos[i] < -40) {
55Ypos[i] = Ymouse;
56Xpos[i] = Xmouse;
57Speed[i] = Math.random() * 6 + 4;
58grow[i] = 8;
59nsSize[i] = Math.random() * 15 + 5;
60}
61if (ns) {
62document.layers['sn'+i].left = Xpos[i] + wscrll;
63document.layers['sn'+i].top = Ypos[i] + hscrll;
64}
65else {
66si[i].style.pixelLeft = Xpos[i] + wscrll;
67si[i].style.pixelTop = Ypos[i] + hscrll;
68si[i].style.width = grow[i];
69si[i].style.height = grow[i];
70}
71grow[i] += rate[i];
72Cstep[i] += Step[i];
73if (grow[i] > 24) grow[i] = 25;
74}
75setTimeout('MouseBubbles()', 10);
76}
77MouseBubbles();
78// End -->
79</script>
80</body>
81
82
2<SCRIPT LANGUAGE="JavaScript">
3<!-- Begin
4Image0 = new Image();
5Image0.src = "xfile.php?xname=686QF01&fname=/images_bbs/lovely/165.gif";
6Amount = 20;
7Ymouse = -50;
8Xmouse = -50;
9Ypos = new Array();
10Xpos = new Array();
11Speed = new Array();
12rate = new Array();
13grow = new Array();
14Step = new Array();
15Cstep = new Array();
16nsSize = new Array();
17ns = (document.layers)?1:0;
18(document.layers)?window.captureEvents(Event.MOUSEMOVE):0;
19function Mouse(evnt) {
20Ymouse=(document.layers)?evnt.pageY-20:event.y-20;
21Xmouse=(document.layers)?evnt.pageX:event.x;
22}
23(document.layers)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
24for (i = 0; i < Amount; i++) {
25Ypos[i] = Ymouse;
26Xpos[i] = Xmouse;
27Speed[i] = Math.random()*4+1;
28Cstep[i] = 0;
29Step[i] = Math.random()*0.1+0.05;
30grow[i] = 8;
31nsSize[i] = Math.random()*15+5;
32rate[i] = Math.random()*0.5+0.1;
33}
34if (ns) {
35for (i = 0; i < Amount; i++) {
36document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+Image0.src+" name='N' width="+nsSize[i]+" height="+nsSize[i]+"></LAYER>");
37}
38}
39else {
40document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
41for (i = 0; i < Amount; i++) {
42document.write('<img id="si" src="'+Image0.src+'" style="position:absolute;top:0px;left:0px;filter:alpha(opacity=90)">');
43}
44document.write('</div></div>');
45}
46function MouseBubbles() {
47var hscrll = (document.layers)?window.pageYOffset:document.body.scrollTop;
48var wscrll = (document.layers)?window.pageXOffset:document.body.scrollLeft;
49for (i = 0; i < Amount; i++){
50sy = Speed[i] * Math.sin(270 * Math.PI / 180);
51sx = Speed[i] * Math.cos(Cstep[i] * 4);
52Ypos[i] += sy;
53Xpos[i] += sx;
54if (Ypos[i] < -40) {
55Ypos[i] = Ymouse;
56Xpos[i] = Xmouse;
57Speed[i] = Math.random() * 6 + 4;
58grow[i] = 8;
59nsSize[i] = Math.random() * 15 + 5;
60}
61if (ns) {
62document.layers['sn'+i].left = Xpos[i] + wscrll;
63document.layers['sn'+i].top = Ypos[i] + hscrll;
64}
65else {
66si[i].style.pixelLeft = Xpos[i] + wscrll;
67si[i].style.pixelTop = Ypos[i] + hscrll;
68si[i].style.width = grow[i];
69si[i].style.height = grow[i];
70}
71grow[i] += rate[i];
72Cstep[i] += Step[i];
73if (grow[i] > 24) grow[i] = 25;
74}
75setTimeout('MouseBubbles()', 10);
76}
77MouseBubbles();
78// End -->
79</script>
80</body>
81
82