萬盛學電腦網

 萬盛學電腦網 >> 腳本專題 >> javascript >> JavaScript實現鼠標滑過處生成氣泡的方法

JavaScript實現鼠標滑過處生成氣泡的方法

   本文實例講述了JavaScript實現鼠標滑過處生成氣泡的方法。分享給大家供大家參考。具體實現方法如下:

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 <HTML> <HEAD> <title>鼠標周圍在網頁上生成氣泡</title> </HEAD> <BODY bgColor=#000000 scroll=no onload=zyva()> <div id=aqua style="position:absolute;left=0;top=0;"></div> <IMG id=B src="b1.gif" style="display:none"> <SCRIPT> object = new Array() var xm,ym function CObj(N,obj){ aqua.insertAdjacentHTML("AfterBegin","<img style='position:absolute;left:-1000;' src='"+obj.src+"'>") this.img = aqua.firstChild.style mr = Math.random() this.v = 6*mr+4 this.s = .5*mr this.p = .1+mr this.w = 0 this.k = 0 this.x = xm this.y = N this.ChteuMeulEu = function ChteuMeulEu(){ with(this){ with(img){ left = (x+=0.5*v*Math.sin(k+=s))-w*0.5 top = y-=v width = Math.min(w+=p,100) } if(y<-w){ w = 8 y = ym x = xm } } } } function gradient(R,G,B,m){ for(i=0;i<25;i++){ c = 255 - 10 * i C = ""RGB("+Math.round(c*R/255)+","+Math.round(c*G/255)+","+Math.round(c*B/255)+")"" code = "<span style='position:absolute;font-size:1pt;left=0;width=120%;height="+(m)+".2%;top="+(i*m) +"%;background="+C+";z-Index:-1000'></span>" document.body.insertAdjacentHTML("beforeEnd",code) } } function zyva(){ xm = document.body.offsetWidth * 0.5 ym = document.body.offsetHeight document.onmousemove = function (){ xm = window.event.clientX ym = window.event.clientY } for(i=0;i<60;i++)object[i] = new CObj(i,B) setInterval("for(i in object)object[i].ChteuMeulEu()",16) gradient(41,93,214,2) } </SCRIPT> </BODY> </HTML>

  希望本文所述對大家的javascript程序設計有所幫助。

copyright © 萬盛學電腦網 all rights reserved