Skip to content

Instantly share code, notes, and snippets.

@fiture
Last active December 23, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiture/6645811 to your computer and use it in GitHub Desktop.
Save fiture/6645811 to your computer and use it in GitHub Desktop.
兼容IE的Image loaded.
function loadImage(src, $img) {
var me = arguments.callee;
$img
.load(function(){
if ( $img.width() && $img.height() ) {
//获取宽度
} else {
//延时,递归再次调用
setTimeout(function(){
me(src, $img);
} , 500);
}
})
.error(errorHandler);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment