1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<!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>Document sans nom</title>
<script type="text/javascript">
//########################## Fonction permettant de remplacer "document.getElementById" ########################## //
function $(element){
return document.getElementById(element);
}
var timer = null;
//Permet de faire glisser une div de la gauche vers la droite
function slideUp(bigMenu,smallMenu){
//Si le timer n'est pas finit on détruit l'ancienne div
if(parseInt($(bigMenu).style.left) < 0){
$(bigMenu).style.left = parseInt($(bigMenu).style.left) + 10 + "px";
$(smallMenu).style.left =parseInt($(smallMenu).style.left) + 10 + "px";
timer = setTimeout('slideUp("'+bigMenu+'","'+smallMenu+'")',10);
}
else{
clearTimeout(timer);
TimerRunning = false;
//$(smallMenu).parentNode.removeChild($(smallMenu));
//alert("timer up bien kill");
}
}
//Permet de faire glisser une div de la droite vers la gauche
function slideDown(bigMenu,smallMenu){
if(parseInt($(bigMenu).style.left) > 0){
$(bigMenu).style.left = parseInt($(bigMenu).style.left) - 10 + "px";
$(smallMenu).style.left =parseInt($(smallMenu).style.left) - 10 + "px";
timer = setTimeout('slideDown("'+bigMenu+'","'+smallMenu+'")',10);
}
else{
clearTimeout(timer);
TimerRunning = false;
//delete de l'ancienne
//$(smallMenu).parentNode.removeChild($(smallMenu));
//alert("timer down bien kill");
}
}
</script>
</head>
<body>
<div id="conteneur" style="overflow:hidden;width:200px;height:200px;background-color:#FF0000;position:relative">
<div id="gauche" style="position:absolute;top:0px;left:-200px;background-color:#00FF00;width:200px;height:200px;"></div>
<div id="origine" style="position:absolute;top:0px;left:0px;background-color:#0000FF;width:200px;height:200px;"></div>
<div id="droite" style="position:absolute;top:0px;left:200px;background-color:#FFFF00;width:200px;height:200px;"></div>
</div>
<a href="#" onclick="slideUp('gauche','origine')">faire glisser a droite</a>
<a href="#" onclick="slideDown('droite','origine')">faire glisser a gauche</a>
</body>
</html> |