Hello,

Je souhaite faire varier la hauteur d'une liste en fonction du temps pass�.

Pour cela, j'ai �crit le code suivant :
Code : S�lectionner tout - Visualiser dans une fen�tre � part
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
59
60
61
62
63
64
65
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<title>Exemple</title>
		<script type="text/javascript"><!--
 
var connect = function(oEl, sEvType, fn, bCapture) {
	return document.addEventListener ?
		oEl.addEventListener(sEvType, fn, bCapture || false):
		oEl.attachEvent ?
			oEl.attachEvent('on' + sEvType, fn):
			false;
};
 
var load = function() {
 
	var oUl = document.getElementsByTagName('ul')[0];
 
	var initAnim = function() {
		oUl.style.height = 0;
		oUl.style.overflow = 'hidden';
		oUl.start = (new Date()).getTime();
		oUl.opened = oUl.start + 1000;
	};
 
	var stopAnim = function() {
		oUl.style.height = 'auto';
		oUl.style.overflow = 'visible';
		oUl.start = oUl.opened = null;
		clearInterval(oUl.exe);
	};
 
	var anim = function() {
		if(!oUl.opened) initAnim();
		var currentTime = (new Date()).getTime();
		var currentHeight = parseInt(oUl.style.height);
		if(currentHeight < oUl.scrollHeight && currentTime < oUl.opened ) {
			currentHeight = currentTime * oUl.scrollHeight / oUl.opened;
			oUl.style.height = parseInt(currentHeight) + 'px';
		}
		else stopAnim();
	};
 
	oUl.exe = setInterval(anim, 1);
 
};
 
connect(window, 'load', load);
 
		//--></script>
	</head>
	<body>
 
<ul>
	<li>item 1</li>
	<li>item 2</li>
	<li>item 3</li>
	<li>item 4</li>
	<li>item 5</li>
</ul>
 
	</body>
</html>
Actuellement, la liste s'ouvre d'un coup sans tenir compte de mon code. Sauriez-vous pourquoi et d'o� provient mon erreur ?