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 |
Partager