Bonjour,
Je suis novice en js. Mon problème est le suivant: j'ai intégré une fonction fadepic à mon code mais j'aimerais empêcher les images d'apparaitre une première fois avant que le fondu ne s'enclenche... Comment faire?
Voici mon code:
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 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <link rel="stylesheet" type="text/css" href="style2.css"> <title>Fading Pic</title> </head> <body> <div id= "img0"> <img id="C3a" src="http://www.developpez.net/forums/images/img/C3a.jpg" width=225 height=150 style="-moz-opacity:0;filter:alpha(opacity=0)"> </div> <div id ="img1"><img id="R1a" src="http://www.developpez.net/forums/images/img/R1a.jpg" width=225 height=150 style="-moz-opacity:0;filter:alpha(opacity=0)"></div> <div id ="img2"><img id="W2a" src="http://www.developpez.net/forums/images/img/W2a.jpg" width=225 height=150 style="-moz-opacity:0;filter:alpha(opacity=0)"></div> </body> <script> var max = 100; var min = 0; var opacite=min; up=true; var IsIE=!!document.all; var ThePic=document.getElementById; function fadePic(){ if (opacite<max && up){opacite+=2;} if (opacite>min && !up){opacite-=2;} if (opacite>=max){up=false;} if (opacite<=min){up=true;} IsIE?ThePic.filters[0].opacity=opacite:document.getElementById("W2a").style.opacity=opacite/100; IsIE?ThePic.filters[0].opacity=opacite:document.getElementById("R1a").style.opacity=opacite/100; IsIE?ThePic.filters[0].opacity=opacite:document.getElementById("C3a").style.opacity=opacite/100; document.getElementById('result').value=opacite+"%" } setInterval(function(){fadePic();},100) </script> </body> </html>
Partager