0, l = aUl.length; i < l; i++) { var _h = aUl[i].getAttribute('attr'); var _load = aUl[i].getAttribute('load'); if(t>parseInt(_h) && _load !=1 && _h != null){ setTimeout("setImg(" + i + ")", 300); } } } }; function getH(obj) { var h = 0; while (obj) { h += obj.offsetTop; obj = obj.offsetParent; } return h; } function setImg(index){ var aLi = $('.'+LoadclassName).eq(index).find('img'); for (var j = 0; j < aLi.length; j++) { var src = aLi.eq(j).attr('data-src'); aLi.eq(j).attr('src',src); } $('.'+LoadclassName).eq(index).attr('load','1'); } window.onload = function () { var modelName = "product"; if(modelName == 'index'){ LoadclassName = 'ind_img_load'; }else if(modelName == 'company'){ LoadclassName = 'rec_rbox'; }else{ LoadclassName = 'floor_prolist'; } var aUl = document.getElementsByClassName(LoadclassName); for (var i = 0, l = aUl.length; i < l; i++) { var h = getH(aUl[i]); aUl[i].setAttribute('attr',h); } window.onscroll(); };