Portal    Foro    Buscar    FAQ    Registrarse    Conectarse


JanuWeb.Com  Informa

JanuWeb es una Comunidad abierta a todos los internautas.
Pero algunos de sus contenidos (Adjuntos, Descargas, Grupos...) sólo son accesibles a usuarios registrados.

Regístrate y disfruta al completo de la web.



Publicar Nuevo Tema  El tema está bloqueado: no pueden editarse ni agregar mensajes. Página 1 de 1
 
Efecto de caida de nieve en Javascript.
Autor Mensaje
Responder Citando
Mensaje Efecto de caida de nieve en Javascript. 
 
Este codigo ha sido publicado por class en un tema de este foro.
Y lo publico aqui para tenerlo recodigo.
Gracias class.

Código: [Descargar] [Ocultar]
  1. <script>  
  2. var no = 5; // snow number  
  3. var speed = 15; // smaller number moves the snow faster  
  4. var snowflake = "imagennieve.gif";  
  5.  
  6. var ns4up = (document.layers) ? 1 : 0;  // browser sniffer  
  7. var ie4up = (document.all) ? 1 : 0;  
  8. var dx, xp, yp;    // coordinate and position variables  
  9. var am, stx, sty;  // amplitude and step variables  
  10. var i, doc_width = 400, doc_height = 500;  
  11. if (ns4up) {  
  12.  doc_width = self.innerWidth;  
  13.  doc_height = self.innerHeight;  
  14. } else if (ie4up) {  
  15.  doc_width = 500;  
  16.  doc_height = 500;  
  17. }  
  18. dx = new Array();  
  19. xp = new Array();  
  20. yp = new Array();  
  21. am = new Array();  
  22. stx = new Array();  
  23. sty = new Array();  
  24. for (i = 0; i < no; ++ i) {    
  25.  dx[i] = 0;                        // set coordinate variables  
  26.  xp[i] = Math.random()*(doc_width-50);  // set position variables  
  27.  yp[i] = Math.random()*doc_height;  
  28.  am[i] = Math.random()*20;         // set amplitude variables  
  29.  stx[i] = 0.02 + Math.random()/10; // set step variables  
  30.  sty[i] = 0.7 + Math.random();     // set step variables  
  31.  if (ns4up) {                      // set layers  
  32.    if (i == 0) {  
  33.      document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");  
  34.      document.write("top=\"15\" visibility=\"show\"><img src=\"");  
  35.      document.write(snowflake + "\" border=\"0\"></layer>");  
  36.    } else {  
  37.      document.write("<layer name=\"dot"+ i +"\" left=\"15\" ");  
  38.      document.write("top=\"15\" visibility=\"show\"><img src=\"");  
  39.      document.write(snowflake + "\" border=\"0\"></layer>");  
  40.    }  
  41.  } else if (ie4up) {  
  42.    if (i == 0) {  
  43.      document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");  
  44.      document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");  
  45.      document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");  
  46.      document.write(snowflake + "\" border=\"0\"></div>");  
  47.    } else {  
  48.      document.write("<div id=\"dot"+ i +"\" style=\"POSITION: ");  
  49.      document.write("absolute; Z-INDEX: "+ i +"; VISIBILITY: ");  
  50.      document.write("visible; TOP: 15px; LEFT: 15px;\"><img src=\"");  
  51.      document.write(snowflake + "\" border=\"0\"></div>");  
  52.    }  
  53.  }  
  54. }  
  55. function snowNS() {  // Netscape main animation function  
  56.  for (i = 0; i < no; ++ i) {  // iterate for every dot  
  57.    yp[i] += sty[i];  
  58.    if (yp[i] > doc_height-50) {  
  59.      xp[i] = Math.random()*(doc_width-am[i]-30);  
  60.      yp[i] = 0;  
  61.      stx[i] = 0.02 + Math.random()/10;  
  62.      sty[i] = 0.7 + Math.random();  
  63.      doc_width = self.innerWidth;  
  64.      doc_height = self.innerHeight;  
  65.    }  
  66.    dx[i] += stx[i];  
  67.    document.layers["dot"+i].top = yp[i];  
  68.    document.layers["dot"+i].left = xp[i] + am[i]*Math.sin(dx[i]);  
  69.  }  
  70.  setTimeout("snowNS()", speed);  
  71. }  
  72.  
  73. function snowIE() {  // IE main animation function  
  74.  for (i = 0; i < no; ++ i) {  // iterate for every dot  
  75.    yp[i] += sty[i];  
  76.    if (yp[i] > doc_height-50) {  
  77.      xp[i] = Math.random()*(doc_width-am[i]-30);  
  78.      yp[i] = 0;  
  79.      stx[i] = 0.02 + Math.random()/10;  
  80.      sty[i] = 0.7 + Math.random();  
  81.      doc_width = document.body.clientWidth;  
  82.      doc_height = document.body.clientHeight;  
  83.    }  
  84.    dx[i] += stx[i];  
  85.    document.all["dot"+i].style.pixelTop = yp[i];  
  86.    document.all["dot"+i].style.pixelLeft = xp[i] + am[i]*Math.sin(dx[i]);  
  87.  }  
  88.  setTimeout("snowIE()", speed);  
  89. }  
  90.  
  91. if (ns4up) {  
  92.  snowNS();  
  93. } else if (ie4up) {  
  94.  snowIE();  
  95. }  
  96. </script> 






_________________________________
Image
Desconectado MSN Messenger Skype Yahoo Messenger Ver perfil del usuario Enviar Mensaje Privado Visitar sitio Web del Usuario Ver la Galería Personal del usuario
Descargar Mensaje Volver arriba Página Inferior
Gracias por el tema tan útil, JANU1535:
ASLAN (12 Diciembre) 
Mostrar mensajes anteriores:   
Ocultar¿Este tema fue útil?
Compartir este tema
blinkslist.com blogmarks.net co.mments.com del.icio.us digg.com newsvine.com facebook.com fark.com feedmelinks.com furl.net google.com linkagogo.com ma.gnolia.com meneame.net netscape.com reddit.com shadows.com simpy.com slashdot.org smarking.com spurl.net stumbleupon.com technorati.com favorites.live.com yahoo.com DIGG ITA Fai Informazione KiPapa Ok Notizie Segnalo

Publicar Nuevo Tema  El tema está bloqueado: no pueden editarse ni agregar mensajes.  Página 1 de 1
 

Usuarios navegando en este Tema: 0 Registrados, 0 Ocultos y 1 Invitado
Usuarios Registrados conectados: Ninguno


 
Lista de Permisos
No puede crear mensajes
No puede responder temas
No puede editar sus mensajes
No puede borrar sus mensajes
No puede votar en encuestas
No puede adjuntar archivos
No Puede descargar archivos
Puede enviar eventos al Calendario



  



 

JanuWeb.Com  Destaca


JanuWeb.ComJanuWeb.OrgJanuBlog.Com están alojadas en Sotem.es • © 2006, 2008

MuchoGrafico - Paz y Justicia - phpBB-Es - Icy Phoenix España - Ciber Morph - Lphant - EDDB - CoMuNiDaD ThE KuKa
RYLNet - phpBBMODs.Es - ZonaManolo - Directorio phpBB-Es - ModMovil - AyudaPC - Mas Pi - Madelman