Originariamente inviato da artorius
Non è male, ma la funzione va soltanto su Opera e (penso) su Explorer.
Firefox e Safari no.

Non saprei dirti il motivo, ma pare che su Firefox le funzioni non vengano chiamate...
Codice PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<
html>
<
head>
<
title>JavaScript div move</title>
<
meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<
script  type="text/javascript">

var 
animation = {
    
x0,
    
timerundefined,
    
curX0,
    
millisec30,
    
moveRight: function(id){
        var 
self this;    
        var 
layerElement document.getElementById(id);     
        
self.x+=10;
        
layerElement.style.left=self.x;
        var 
timer setTimeout(function(){self.moveRight(id)},self.millisec);
        
self.timer timer;
        
self.curX self.x;
    },
    
    
clearTimer: function(){ 
        var 
self this;
        
clearInterval(self.timer);
    },
    
    
moveLeft: function(id){
        var 
self this;
        var 
layerElement document.getElementById(id);
        
self.x-=10;
        
layerElement.style.left=self.x;
        var 
timer setTimeout(function(){self.moveLeft(id)},self.millisec);
        
self.timer timer;
        
self.curX self.x;
    }
}

</script>
<style type="text/css">
#cont{
    position: relative;
    width: 600px;
    height: 400px;
    background: #ccff00;
    overflow: hidden;
}
#box{
    position: absolute;
    width: 100px;
    height: 100px;
    background: #ccc;
}
</style>

</head>

<body>
<div id="cont">
    <div id="box">il mio box !</div>
</div>



<input type="BUTTON" value="left" onmousedown="animation.moveLeft('box')" onmouseup="animation.clearTimer()">
<input type="BUTTON" value="right" onmousedown="animation.moveRight('box')" onmouseup="animation.clearTimer()">
</p>

</body>
</html> 
testato su:
- WIn IE 6.0 ok
- Win Opera 9.51 ok
- Win Mozilla Firefox 2.0.0.13 ok