在网站上,有一个带有淡化图片的幻灯片,另一个是水平滚动的新标签。两者都用javascript动画。 让我感到困惑的是,在图片渐渐消失之初,新版本会停止滚动片刻。这似乎在很大程度上取决于浏览器可用的资源。
如何让两个脚本顺利运行?
这是用于淡化图片的代码:
this.b_slidenow = function(){
var check1,maxalpha,curralpha;
check1=ptofade.style.MozOpacity;
maxalpha=(100-factor*u)/100*105;
if(check1<=maxalpha/100){u=u+1;}
curralpha=100-factor*u;
ptofade.style.filter="Alpha(Opacity="+curralpha+")";
ptofade.style.MozOpacity=curralpha/100;
ptofade.style.opacity=curralpha/100;
if(u<steps){ //slide not finished
if(stopit=="0"){mytimeout=setTimeout(function(){self.b_slidenow();},ftim);}
else {this.b_slide();}
}
else{ //slide finished
if(startim<emax){
ptofade.style.visibility="hidden";
ptofade.style.zIndex=1;
pnext.style.zIndex=2;
startim=startim+1;u=0;
mytimeout=setTimeout(function(){self.b_slide();},stim);
}
else{
ptofade.style.visibility="hidden";
ptofade.style.zIndex=1;
pnext.style.zIndex=2;
startim=1;u=0;
mytimeout=setTimeout(function(){self.b_slide();},stim);
}
}
}
这是用于滚动代码的代码:
function TICKER_tick() {
if(!TICKER_PAUSED) document.getElementById(ticker).scrollLeft += TICKER_SPEED * (TICKER_RIGHTTOLEFT ? -1 : 1);
if(TICKER_RIGHTTOLEFT && document.getElementById(ticker).scrollLeft <= 0) document.getElementById(ticker).scrollLeft = document.getElementById(ticker).scrollWidth - document.getElementById(ticker).offsetWidth;
if(!TICKER_RIGHTTOLEFT && document.getElementById(ticker).scrollLeft >= document.getElementById(ticker).scrollWidth - document.getElementById(ticker).offsetWidth) document.getElementById(ticker).scrollLeft = 0;
window.setTimeout("TICKER_tick()", 20);
}
该网站仅适用于内部自助服务终端屏幕,并将使用Chrome进行渲染。