Bonjour,
Je cherche à afficher une image dynamiquement, suite à sa sélection. Si elle est sur le serveur, je l'affiche.
Ai-je réellement besoin de préciser que ça fonctionne excellemment bien sous FF et pas du tout sous IE ?
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 var logo = document.getElementById("fileLogo").value; //We retrieve the logo name from the input file var image = document.getElementById("logoImage"); //We retrive the <img> logo = "url"+logo+"?"+new Date().getTime(); //To create the url + timeStamp to avoid the cache image.onload = function() //If the logo exists on the server { alert("onLoad"); image.style.display = "inline"; //To display the image resizeLogo(image); //function that will resize the image }; image.onerror = function() //The logo doesn't exist { alert("onNotLoad"); image.style.display = "none"; //To hide the image }; image.src = logo; //To attribute the url to the image: if wrong onError, else onLoad function
En fait, j'ai l'impression qu'il y a un problème avec le "onload()"
Partager