Bonjour, mon code doit normalement afficher deux div, un avec une opacité de 100% et l'autre avec une opacité de 50%
cependant il ne fonctionne que sous FF alors que normalement sous ie il doit fonctionner aussi.
j'ai lu attentivement vos autre messages notament celui de SpaceFrog avec son script d'opacitéle résultat fonctionne d'ailleurs très bien et le code est vraiment court, mais il devrait le commenter car je le comprends pas completement moi qui suit débutant
.
si quelqu'un peu trouver le bug dans mon pti code ça serait cool
merci
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 <html> <head> <title> </title> </head> <body> <div id="magenta100" style="background-color: #0FF;"> une div avec un fond magenta à 100%. </div> <div id="magenta50" style="background-color: #0FF"> une div avec un fond magenta à 50%. </div> <script type="text/javascript"> function Browser() { if(navigator.userAgent.indexOf('Opera')!=-1) this.opera = true; if(navigator.userAgent.indexOf('konqueror')!=-1) this.Konqueror = true; if(navigator.userAgent.indexOf('Safari')!=-1) this.Safari = true; if(navigator.userAgent.indexOf('Firefox/1.0')!=-1) this.ff10 = true; if(navigator.userAgent.indexOf('Firefox/1.5')!=-1) this.ff15 = true; if(navigator.userAgent.indexOf('Netscape/7.0')!=-1) this.netscape = true; if(navigator.userAgent.indexOf('MSIE 7')!=-1) this.ie7 = true; if(navigator.userAgent.indexOf('MSIE 6')!=-1) this.ie6 = true; //fonction qui affecte l'opacité this.setOpacity = function(el, valeur) //sous IE { if(this.ie7 || this.ie6) { alert('c est IE 6 OU 7 '); var op = parseInt(valeur*100); alert(op); el.style.filter = 'alpha(opacity='+op+')'; } //sous les autres navigateurs else { el.style.opacity = valeur; } } } function $(el) { return document.getElementById(el); } //on instancie l'objet browser var browser = new Browser(); //On applique une opacité à une div browser.setOpacity($('magenta50'), 0.5); </script> </body> </html>
Partager