une galerie compatibilité IE vs FFX
Bonsoir à tous,
voila j'ai fais une galerie d'image et j'ai modifié mon code pour qu'il fonction aussi sur IE mais ça ne fonctionne pas et je ne trouve pas où est ma faute. Je précise que sous Firefox, la galerie fonctionne correctement.
Merci d'avance
-----------------------------------------------------
Code:
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
| var IE = typeof window.attachEvent != "undefined" ;
var FF = typeof window.addEventListener != "undefined" ;
if (FF) {
window.addEventListener("load", init, false);
}
if (IE) {
window.attachEvent("onload", init);
}
function init() {
var photos=document.getElementsByTagName("img");
for (i = 0 ; i < photos.length ; i++) {
if (photos[i].className == "vignette") {
photos[i].title = photos[i].alt ;
if(FF) {photos[i].addEventListener("click", changePhoto, false)};
if(IE) {photos[i].attachEvent("onclick", changePhoto);};
} ;
}
}
function changePhoto(e) {
var alt = e.target.alt ;
var p = alt.indexOf("_") ;
var radical = alt.slice(0,p) ;
var url = "../photos/" + radical + "_500.jpg" ;
var cible = document.getElementById("grandePhoto") ;
cible.src = url ;
} |