标签:indicator order ges ini interval ide tar src val
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style> *{margin:0;padding:0;} .main{width:800px;margin:50px auto;border:1px solid #ccc;} .main li{float:left;width:50%;} .main ul{overflow:hidden;} .main li img{width:100%;} li{list-style: none;} </style> <script src="src.js"></script> </head> <body> <div class="main"> <ul> <li> <img src="https://img13.360buyimg.com/mobilecms/s80x80_jfs/t3607/53/1645824653/56317/14fbe587/582eb3d7N41fdab12.jpg!q90.webp" onload="imgObj(‘https://img14.360buyimg.com/n4/s130x130_jfs/t3358/84/1745747532/247590/ebbfc20e/58340651N16910ec9.jpg!q90.webp‘)"> </li> </ul> </div> </body> </html>
function imgObj(src){ var _src = src+‘?datetime=‘+new Date().getTime(); /** * 加载图片,直到加载完成后才调用回调函数 * @param url 后面读取图片流的url * @param callback 回调函数 */ function loadImage(url, callback) { var img = new Image(); img.src = url; var timer = setInterval(function() { if (img.complete) { callback(img); clearInterval(timer); } }, 50); } /** *图片加载完成 */ function testFun(_ele){ console.log(‘into testFun‘); } loadImage(_src,testFun); }
标签:indicator order ges ini interval ide tar src val
原文地址:http://www.cnblogs.com/zhujiasheng/p/6241704.html