两个js文件冲突,单独放在一个可以用,要是二个一起引用进来就有一个失败

top.js如下:window.onload=function(){varlistItem=document.getElementById("homePushShow")... top.js如下:
window.onload=function(){
var listItem=document.getElementById("homePushShow");
var tList=document.getElementById("homePushName").childNodes;
var controlItem=[];
for(var i=0;i<tList.length;i++){
if(tList[i].nodeName.toLowerCase()=="li"){
controlItem.push(tList[i]);
}
}
var picCount=controlItem.length;
var cid=0;
var tid=Math.floor(Math.random()*picCount);
window.cTop=0
window.gTop=0;
window.speed=0;
window.controlAction="";
window.timeCount=0;
setInterval(function(){
if(cid!=tid){
gTop=tid*170;
speed=(gTop-cTop)/10;
cid=tid;
for(var i=0;i<picCount;i++){
controlItem[i].className=((i==cid)?"current":"");
}
}
if(window.cTop!=window.gTop){
window.cTop+= parseInt(speed);
listItem.style.marginTop="-"+ parseInt(window.cTop)+"px";
}
document.getElementById("homePushBg").style.display="block";
document.getElementById("homePushName").style.display="block";
},20);
//
for(var i=0;i<picCount;i++){
controlItem[i].onmouseover=function(){
var goId=parseInt(this.innerHTML)-1;
clearTimeout(window.controlAction);
window.controlAction=setTimeout(function(){
tid=goId;
timeCount=0;
},300);
}
controlItem[i].onmouseout=function(){
clearTimeout(window.controlAction);
}
}
//
setInterval(function(){
timeCount+=1
if(timeCount>=5){
window.controlAction=setTimeout(function(){
tid=tid+1;
if(tid>=picCount){tid=0;}
},20);
timeCount=0;
}
},1000);
var mDD = document.getElementById("tablit").getElementsByTagName("dd");
var mDIV= document.getElementById("tablit").getElementsByTagName("div");
for (var i=0;i<mDD.length;i++){
(function(index) {
mDD[index].onmouseover = function() {
if (mDD[index].className == 'out') {
for (var j = 0; j < mDD.length; j++) {
mDD[j].className = 'out';
mDIV[j].style.display = 'none';
}
mDD[index].className = 'on';
mDIV[index].style.display = 'block';
}
}
})(i);
}
}
if(pr==i){
hxs[i].className+=" up"; // 展开状态:标题
boxsClass[i].className+=" up"; // 展开状态:容器
}
else {
hxs[i].className=hxs[i].tmpClass;
boxsClass[i].className=boxsClass[i].tmpClass;
}
}
}
}//
tab_zzjs("tab_zzjs_2","h4","ol");tab_zzjs("tab_zzjs_1","h3","div","","onclick",2);
}
展开
 我来答
lxs_lingting
推荐于2016-05-02 · TA获得超过990个赞
知道小有建树答主
回答量:899
采纳率:100%
帮助的人:515万
展开全部

底下多出几个 }  

    window.onload=function()
    {
        var listItem=document.getElementById("homePushShow");
        var tList=document.getElementById("homePushName").childNodes;
        var controlItem=[];
        for(var i=0;i<tList.length;i++)
        {
            if(tList[i].nodeName.toLowerCase()=="li")
            {
                controlItem.push(tList[i]);
            }
        }
        var picCount=controlItem.length;
        var cid=0;
        var tid=Math.floor(Math.random()*picCount);
        window.cTop=0
        window.gTop=0;
        window.speed=0;
        window.controlAction="";
        window.timeCount=0;
        setInterval(function()
        {
            if(cid!=tid)
            {
                gTop=tid*170;
                speed=(gTop-cTop)/10;
                cid=tid;
                for(var i=0;i<picCount;i++)
                {
                    controlItem[i].className=((i==cid)?"current":"");
                }
            }
            if(window.cTop!=window.gTop)
            {
                window.cTop+= parseInt(speed);
                listItem.style.marginTop="-"+ parseInt(window.cTop)+"px";
            }
            document.getElementById("homePushBg").style.display="block";
            document.getElementById("homePushName").style.display="block";
        },20);
        //
        for(var i=0;i<picCount;i++)
        {
            controlItem[i].onmouseover=function()
            {
                var goId=parseInt(this.innerHTML)-1;
                clearTimeout(window.controlAction);
                window.controlAction=setTimeout(function()
                {
                    tid=goId;
                    timeCount=0;
                },300);
            }
            controlItem[i].onmouseout=function(){
                clearTimeout(window.controlAction);
            }
        }
        //
        setInterval(function()
        {
            timeCount+=1
            if(timeCount>=5)
            {
                window.controlAction=setTimeout(function()
                {
                    tid=tid+1;
                    if(tid>=picCount){tid=0;}
                },20);
                timeCount=0;
            }
        },1000);
        var mDD = document.getElementById("tablit").getElementsByTagName("dd");
        var mDIV= document.getElementById("tablit").getElementsByTagName("div");
        for (var i=0;i<mDD.length;i++)
        {
            (function(index) 
            {
                mDD[index].onmouseover = function() 
                {
                    if (mDD[index].className == 'out') 
                    {
                        for (var j = 0; j < mDD.length; j++) 
                        {
                            mDD[j].className = 'out';
                            mDIV[j].style.display = 'none';
                        }
                        mDD[index].className = 'on';
                        mDIV[index].style.display = 'block';
                    }
                }
            })(i);
        }
    }
    if(pr==i)
    {
        hxs[i].className+=" up"; // 展开状态:标题
        boxsClass[i].className+=" up"; // 展开状态:容器
    }
    else 
    {
        hxs[i].className=hxs[i].tmpClass;
        boxsClass[i].className=boxsClass[i].tmpClass;
    }
    tab_zzjs("tab_zzjs_2","h4","ol");
    tab_zzjs("tab_zzjs_1","h3","div","","onclick",2);
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式