Ver Mensaje Individual
  #5 (permalink)  
Antiguo 19/06/2009, 03:22
Avatar de angeldelolmo
angeldelolmo
 
Fecha de Ingreso: junio-2008
Mensajes: 109
Antigüedad: 15 años, 11 meses
Puntos: 1
Respuesta: divs apareciendo aleatoriamente

Gracias KiraSakuya ;)

He puesto esto y no me funciona, no se si tengo que aplicarle algún estilo al div o algo.... He llamado a la función en el body onload, no se si es correcto...

Y cómo hago para poner varios divs???
Esque no se si me he explicado bien, tienen que ser varios div y que en cada momento vaya mostrando uno, siempre en la misma posición, pero cada vez un div aleatoriamente...

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<
title>Documento sin t&#237;tulo</title>
</head>

<
body onload="testtimeout()">
<
div  id="TuDiv">contenido</div>
<
script language="javascript" type="text/javascript">
      var 
posicion = new Array();
      var 
i=0;
      function 
testtimeout(){
      switch (
i)
      {
          case 
0posicion[0]=500;
                  
posicion[1]=100;
                  break;
          case 
1posicion[0]=100;
                  
posicion[1]=500;
                  break;
          case 
2posicion[0]=300;
                  
posicion[1]=300;
                  break;
      }
      var 
randomnumber=Math.floor(Math.random()*11);
      
document.getElementById("TuDiv").style.left=posicion[0]
      var 
randomnumber=Math.floor(Math.random()*11);
      
document.getElementById("TuDiv").style.top=posicion[1]
      
i=Math.floor(Math.random()*3);
      
t=setTimeout("testtimeout()",3000);
      }
</
body>
</
html