Mobile Safari - Reliable Callback For When Image Loads?
I try to load an image as such: var img = new Image(); img.src = 'mars.png'; img.onLoad = callback; function callback(){ // doesnt fire alert('loaded'); } the callbac
Solution 1:
You MUST define the onload BEFORE you change the src and event handlers are lowercase so it is spelled onload
var img = new Image();
img.onload = callback;
img.src = 'mars.png';
function callback(){
alert("loaded");
}
or as I prefer it
var img = newImage();
img.onload = function(){
alert("loaded");
}
img.src = 'mars.png';
Solution 2:
Have you tried these?
var img = newImage();
img.src = 'mars.png';
img.onLoad = function(){
// doesnt firealert("loaded");
};
Solution 3:
mplungjan is right you can use these instead:
img.onload = function(){
// doesnt firealert("loaded");
};
with lower l in onLoad
Post a Comment for "Mobile Safari - Reliable Callback For When Image Loads?"