JavaScript实现鼠标滑过处生成气泡的方法
本文实例讲述了JavaScript实现鼠标滑过处生成气泡的方法。分享给大家供大家参考。具体实现方法如下:
<HTML>
<HEAD>
<title>鼠标周围在网页上生成气泡</title>
</HEAD>
<BODYbgColor=#000000scroll=noonload=zyva()>
<divid=aquastyle="position:absolute;left=0;top=0;"></div>
<IMGid=Bsrc="b1.gif"style="display:none">
<SCRIPT>
object=newArray()
varxm,ym
functionCObj(N,obj){
aqua.insertAdjacentHTML("AfterBegin","<imgstyle='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=functionChteuMeulEu(){
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
}
}
}
}
functiongradient(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="<spanstyle='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)
}
}
functionzyva(){
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]=newCObj(i,B)
setInterval("for(iinobject)object[i].ChteuMeulEu()",16)
gradient(41,93,214,2)
}
</SCRIPT>
</BODY>
</HTML>
希望本文所述对大家的javascript程序设计有所帮助。