Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/12/2009, 10:03
Avatar de jackson666
jackson666
 
Fecha de Ingreso: noviembre-2009
Ubicación: Buenos Aires, Argentina
Mensajes: 1.971
Antigüedad: 15 años, 2 meses
Puntos: 65
Respuesta: Ayuda con funciones en js..

Código HTML:
<html>
<head>
<style type="text/css">
#imagen{position: absolute; top: 0; left: 0;}
</style>
</head>
<body>
<img src="turuta.jpg" alt="algo" id="imagen" />
<form action="#" mehod="GET">
    <input type="button" value="derecha" onclick="derecha();" />
    <input type="button" value="izquierda" onclick="izquierda();" />
    <input type="button" value="arriba" onclick="arriba();" />
    <input type="button" value="abajo" onclick="abajo();" />
</form>

<script type="text/javascript">
var img=document.getElementById("imagen");

var timer;

var contador=0;

function derecha(){

    if(contador<20){

        contador++;

        img.style.left=contador+'px';

        timer=setTimeout("derecha()",50);

    }else{
        clearTimeout(timer);
        contador=0;

    }

}

//el resto te las dejo a vos =)
</script>
</body>
</html>