function companyMove(){ var bigBox=document.getElementById('company_box'); var companyContent=getByClass(bigBox,'company_content'); var oListsWidth=parseInt(getStyle(companyContent[0],'width')); var oListsHeight=getStyle(companyContent[0],'height'); var companyBox=getByClass(bigBox,'company_content_box')[0]; var oBtn=document.getElementById('company_btn'); var aBtnLists=oBtn.getElementsByTagName('a'); var onNow=0; companyContent.timer1=null; companyContent.timer2=null; companyBox.style.width=parseInt(oListsWidth)*companyContent.length+'px'; //alert(companyBox.style.width); //aBtnLists[1].className='company_btn_checked'; function a(){ clearInterval(companyContent.timer2);//清楚第二个定时器 companyContent.timer1=setInterval(function(){//开启第一个定时器 onNow+=-oListsWidth; startMove(companyBox,{left:onNow},15); if(onNow<=-oListsWidth*(companyContent.length-1)) { b(); } for(var i=0 ; i<aBtnLists.length ; i++) { aBtnLists[i].className=''; } aBtnLists[Math.abs(onNow/oListsWidth)].className='company_btn_checked'; },5000); } function b(){ clearInterval(companyContent.timer1); companyContent.timer2=setInterval(function(){ onNow+=oListsWidth; startMove(companyBox,{left:onNow},15); if(onNow>=0) { a(); } for(var i=0 ; i<aBtnLists.length ; i++) { aBtnLists[i].className=''; } aBtnLists[Math.abs(onNow/oListsWidth)].className='company_btn_checked'; },5000); } a(); companyBox.onmouseover=function(){ clearInterval(companyContent.timer1); clearInterval(companyContent.timer2); } companyBox.onmouseout=function(){ a(); } }
我是大牛你信么
相关分类