Ver Mensaje Individual
  #2 (permalink)  
Antiguo 18/09/2011, 11:24
lubtufano
 
Fecha de Ingreso: julio-2011
Mensajes: 220
Antigüedad: 13 años, 7 meses
Puntos: 72
Respuesta: Mover capa al cargar web

Solo se nececita poner la instrucción en el evento 'onLoad' de <body>, de esta manera:

Código Javascript:
Ver original
  1. <script>
  2. inicio=1;
  3. fin=300;
  4. objeto="";
  5. function mover(){
  6. if(inicio<fin){
  7. document.getElementById(objeto).style.left=inicio;
  8. inicio++;
  9. setTimeout("mover()", 5);
  10. }
  11.  
  12. }
  13. </script>
  14. </head>
  15.  
  16. <body onLoad="objeto='capa';mover();">
  17.  
  18. <div id="capa" style="position:relative;border:1px solid #000000;width:100px;height:100px;background-color:Yellow;">Capa que se va ha mover</div>