miércoles, 13 de mayo de 2009

Web - Javascript, nieve en la pagina

Codigo


<script language="JavaScript">
<!--
function propietats (este){
amplada=document.body.offsetWidth
altura=document.body.offsetHeight
este.velositat=Math.floor(Math.random()*palVelocitat+1)
este.style.top=Math.floor(Math.random()*-300)-20+"px"
este.style.fontSize="24px"
este.pal=Math.floor(Math.random()*150)
este.interval=Math.PI/Math.floor(Math.random()*300+100)
este.innerHTML="&#"+(10033+Math.floor(Math.random()*14))+";"
este.leftCentre=Math.floor(Math.random()*(amplada-este.pal*2-este.offsetWidth/2))+este.pal
este.onmouseover=flocClicat

}
function flocClicat(){
this.style.fontSize="48px"
this.tornarFontNormal=10
this.style.top=parseInt(this.style.top)+Math.floor(Math.random()*-50)-50+"px"
}
function mou(){
for(i=0;i<floc.length;i++){
floc[i].style.top=parseInt(floc[i].style.top)+floc[i].velositat+"px"
floc[i].angle+=floc[i].interval
floc[i].style.left=parseInt((floc[i].leftCentre+floc[i].pal*Math.sin(floc[i].angle)))+"px"
tmp=parseInt(floc[i].style.fontSize)
floc[i].style.color="#FFFFFF"
if (tmp>24){
tmp--
floc[i].style.fontSize=tmp+"px"
floc[i].style.color="#ffff00"
}
if (parseInt(floc[i].style.top)>=altura-tmp){
propietats (floc[i])

}
}
}
function inici(){
palVelocitat=3
floc=new Array()
for(i=0;i<50;i++){
nouElement=document.createElement("div");
nouElement.innerHTML="**"
document.body.appendChild(nouElement)
nouElement.style.position="absolute"
nouElement.style.cursor="default"
nouElement.style.zIndex=2
propietats (nouElement)
nouElement.angle=0
floc[i]=nouElement
}


setInterval("mou()",20)




}
inici()
-->
</script>


No hay comentarios:

Publicar un comentario