码迷,mamicode.com
首页 > Web开发 > 详细

js判断图片加载完成

时间:2014-08-02 01:32:52      阅读:372      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   cti   ar   html   

<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>


</head>
<body>

<img id="mainPic" src="http://img1c.xgo-img.com.cn/pics/1843/b1842753.jpg" />


<script>

loadingImg(http://img1c.xgo-img.com.cn/pics/1843/b1842753.jpg,getWH);

function getWH(){
    set(this.width, this.height)
}

function loadingImg(url,fun){
    var _Img = new Image();
    _Img.src = url;
    /*判断是否已加载*/
    (_Img.complete) ? fun : _Img.onload = fun;
}

function set(w,h){
    console.log(w,h)
}
</script>
</body>
</html>

 

js判断图片加载完成,布布扣,bubuko.com

js判断图片加载完成

标签:style   blog   http   color   io   cti   ar   html   

原文地址:http://www.cnblogs.com/dtdxrk/p/3885940.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!