Created
December 18, 2013 02:33
-
-
Save cuing/8016430 to your computer and use it in GitHub Desktop.
图片加载完成
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// script 1 | |
var img = document.getElementById('image1'); | |
img.addEventListener('load', function() { | |
// loaded handing | |
}) | |
img.addEventListener('error', function() { | |
// error handing | |
}) | |
// 上面代码,如果图片在调用事件前加载完成,则不会调用改方法 | |
var img1 = document.getElementById('image1'); | |
function loaded() { | |
} | |
if (img1.complete) { | |
loaded(); | |
} else { | |
img1.addEventListener('load', function() { | |
// loaded handing | |
}) | |
} | |
img1.addEventListener('error', function() { | |
// error handing | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment