I have some very simple code that works in on the desktop with Chrome, Firefox, IE, and Safari on the Desktop, but when I try it on my Iphone it fails.
It's basically
var img1 = document.createElement('img');
img1.onerror = function() {
console.log('img1 fail');
};
img1.onload = function() {
console.log('img1 success');
};
img1.src = 'http://gvgmaps.com/linktothepast/maps/LegendOfZelda-ALinkToThePast-LightWorld.png';
The problem is that on the IPhone the onerror
function runs instead of the onload
. For the desktop the onload
runs just fine and there is no onerror
.
With the fiddle img1 fails for an unknown reason and img2 is a success.
Can someone please tell me how to get the onload to run sucessfully for img1 and img2 on the IPhone?
EDIT:
Very interesting. I resaved the img as a jpg and now it works http://jsfiddle.net/PvY5t/9/ Can someone please provide some color on why this might be.
EDIT2:
These links here seem very relevant
(Really) Long Background Image Does Not Render on iPad Safari