第一种方式,函数式:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "PRototype.doScroll = function() {
var scrollWi = 0;//执行时的宽度
var HimalayaN=document.getElementById(this.boxId).getElementsByTagName("div")[0] ;
var HimalayaW=document.getElementById(this.boxId);
var pointW=(HimalayaN.scrollWidth/HimalayaW.scrollWidth)*100;//原始的宽度比例
var doScr=window.setInterval(function() {
scrollWi += 1;
if (scrollWi >= pointW) {
window.clearInterval(doScr);
} else {
HimalayaN.style.width = scrollWi + "%";
}
}, this.scrollSpeed);
}
var ddddd = new loadingScroll("allBox", 10);
var aaaaa = new loadingScroll("Div1", 10);
ddddd.doScroll();
aaaaa.doScroll();
</script>
</body>
</html>