Source de tp4.html
1: <!DOCTYPE html>
2: <html lang="fr">
3: <head>
4: <title>Actions utilisateur et JavaScript</title>
5: <meta charset="utf-8" />
6: <link rel="stylesheet" href="idemm.css" />
7: <script>
8: var alecran = 'unchat';
9: function diaporama () {
10: if (alecran == 'unchat') {
11: document.getElementById('diapo').setAttribute('src','images/chien.jpg');
12: alecran = 'unchien';
13: } else {
14: document.getElementById('diapo').setAttribute('src','images/chat.jpg');
15: alecran = 'unchat';
16: }
17: }
18: </script>
19: </head>
20:
21: <body onload="chienchat = setInterval('diaporama();',2000);">
22:
23: <h1>Actions utilisateur et JavaScript</h1>
24:
25: <h2>Diaporama automatique</h2>
26:
27: <div class="illustration">
28: <img id="diapo" src="images/chat.jpg" alt="un chat" height="200" />
29: </div>
30:
31: <button onclick="clearInterval(chienchat);">stop!</button>
32:
33: <button onclick="chienchat = setInterval('diaporama();',2000);">on y retourne!</button>
34:
35:
36: </body>
37: </html>
38: