function banner(){ var banner= document.getelementsbyclassname('banner')[0] var bw=banner.getelementsbyclassname('b-wrap')[0] var oul=bw.getelementsbytagname('ul')[0] var num=0 var len=arrimg.length var time=null var flag=true document.onmouseover=function(){ if(flag){ time=setinterval(function(){ num++ bw.style.backgroundimage=arrimg[num%arrimg.length] if(num>len-1){ num=0 } for (var k = 0; k < ali.length; k++) { ali[k].classname = '' } ali[num].classname = 'active' bw.style.backgroundimage = arrimg[num] if(num<0){ num=len-1 } for (var k = 0; k < ali.length; k++) { ali[k].classname = '' } ali[num].classname = 'active' bw.style.backgroundimage = arrimg[num] },2000) flag=false }else { clearinterval(time) time=null flag=true } } var s ='' for(var i=0;i' } oul.innerhtml=s var ali=oul.getelementsbytagname('li') ali[0].classname='active' for (var j = 0; j < ali.length; j++) { ali[j].index = j ali[j].onmouseover = function () { num = this.index for (var k = 0; k < ali.length; k++) { ali[k].classname = '' } ali[num].classname = 'active' bw.style.backgroundimage = arrimg[num] } } } function newsbanner(){ var box =document.getelementbyid('box'); var imga =document.getelementbyid('img1'); var a =document.getelementbyid('url'); var left =document.getelementbyid('left'); var right =document.getelementbyid('right'); var text =document.getelementbyid('text'); var year =document.getelementbyid('newsyear'); var month =document.getelementbyid('newsmonth'); // 构造图片和文字数组 // var arr_url =['','','']; // 图片轮播 var currentindex = 1; var size = newsdata.length; var b = true; function slide(){ b = false; if (typeof newsdata !== 'undefined') { imga.src = newsdata[currentindex].src; imga.classname = newsdata[currentindex].contentid text.innertext =newsdata[currentindex].name year.innertext = newsdata[currentindex].year month.innertext = newsdata[currentindex].month currentindex =++currentindex%size; newsdata[currentindex].contentid; $.each($("#new_num ul > li"),function (i,item){ $(item).attr("id") == newsdata[currentindex].contentid ? $(item).addclass('active') : $(item).removeclass('active') }) b = true; } // a.href = arr_url[currentindex]; } // 使用setinterval完成轮播 var pause =setinterval(slide,2000); // 鼠标悬停时,停止轮播 // 使用clearinterval来完成 box.addeventlistener('mouseover',function(){ clearinterval(pause); }); // 鼠标离开后,继续轮播 box.addeventlistener('mouseout',function(){ pause =setinterval(slide,2000); }) // 手动切换图片 left.addeventlistener('click',function(){ currentindex = --currentindex%size; if(currentindex < 0){ currentindex +=size; } imga.src = newsdata[currentindex].src; text.innertext = newsdata[currentindex].name; year.innertext = newsdata[currentindex].year month.innertext = newsdata[currentindex].month $.each($("#new_num ul >li"),function (index,item){ if($(item).attr("id") == newsdata[currentindex].contentid){ $(item).addclass("active"); $(item).siblings().removeclass("active") } }) }) right.addeventlistener('click',function(){ currentindex =++currentindex%size; imga.src = newsdata[currentindex].src; text.innertext = newsdata[currentindex].name; year.innertext = newsdata[currentindex].year month.innertext = newsdata[currentindex].month $.each($("#new_num ul >li"),function (index,item){ if($(item).attr("id") == newsdata[currentindex].contentid){ $(item).addclass("active"); $(item).siblings().removeclass("active") } }) }) } function btn_newli(obj,id){ var imga =document.getelementbyid('img1'); var text =document.getelementbyid('text'); var year =document.getelementbyid('newsyear'); var month =document.getelementbyid('newsmonth'); $.each(newsdata,function (i,item){ if(item.contentid == id){ imga.src = item.src; text.innertext = item.name; year.innertext = item.year month.innertext = item.month } }) $(obj).addclass("active"); $(obj).siblings().removeclass("active") } function abountusbanner(){ var aboutb =document.getelementbyid('about'); var imgb =document.getelementbyid('img3'); var left =document.getelementbyid('about_left'); var right =document.getelementbyid('about_right'); // 图片轮播 var currentindex =0; var size = aboutimg.length; function slide(){ currentindex = ++currentindex%size ; imgb.src = aboutimg[currentindex]; } // 使用setinterval完成轮播 var pause =setinterval(slide,2000); // 鼠标悬停时,停止轮播 // 使用clearinterval来完成 aboutb.addeventlistener('mouseover',function(){ clearinterval(pause); }); // 鼠标离开后,继续轮播 aboutb.addeventlistener('mouseout',function(){ pause =setinterval(slide,2000); }) left.addeventlistener('click',function(){ currentindex = --currentindex; if(currentindex < 0){ currentindex = aboutimg.length-1; } imgb.src = aboutimg[currentindex]; }) right.addeventlistener('click',function(){ currentindex = ++currentindex; if (currentindex > aboutimg.length-1) { currentindex = 0; } imgb.src = aboutimg[currentindex]; }) }