两个js特效冲突,不知道怎么解决,求大神指导...
window.onload=a;window.onload=showTime;functiona(){varindex=0;vartimer=null;vartemp=d...
window.onload=a;
window.onload=showTime;
function a(){
var index=0;
var timer=null;
var temp=document.getElementById('carousel');
lis=temp.getElementsByTagName('li');
imgs=temp.getElementsByTagName('img');
for(var i=0;i<lis.length;i++){
lis[i].id=i;
lis[i].onmouseover=function(){
clearInterval(timer);
changeOption(this.id);
}
lis[i].onmouseout=function(){
timer=setInterval(autoPlay,2000);
}
}
if(timer){
clearInterval(timer);
timer=null;
}
timer=setInterval(autoPlay,2000);
function autoPlay(){
index++;
if(index>=lis.length){
index=0;
}
changeOption(index);
}
function changeOption(curIndex){
for(var j=0;j<lis.length;j++){
lis[j].style.opacity='0.4';
imgs[j].style.display='none';
}
lis[curIndex].style.opacity='0.9';
imgs[curIndex].style.display='block';
index=curIndex;
}
}
function (){
showTime();
}
function checkTime(z){
if(z<10){
z="0"+z;
}
return z;
}
function showTime(){
var now=new Date();
var year=now.getFullYear();
var month=now.getMonth()+1;
var date=now.getDate();
var h=now.getHours();
var m=now.getMinutes();
var s=now.getSeconds();
h=checkTime(h);
m=checkTime(m);
s=checkTime(s);
var day=now.getDay()
var weekday=new Array(7);
weekday[0]="星期天"
weekday[1]="星期一"
weekday[2]="星期二"
weekday[3]="星期三"
weekday[4]="星期四"
weekday[5]="星期五"
weekday[6]="星期六"
document.getElementById("show").innerHTML=year+"年"+month+"月"+date+"日"+weekday[day]+h+":"+m+":"+s;
setTimeout(showTime,1000);
}
时间代码显示了以后,焦点新闻图就不动了..不知道是怎么回事,我是新手,这些都是参考的别人的写的 展开
window.onload=showTime;
function a(){
var index=0;
var timer=null;
var temp=document.getElementById('carousel');
lis=temp.getElementsByTagName('li');
imgs=temp.getElementsByTagName('img');
for(var i=0;i<lis.length;i++){
lis[i].id=i;
lis[i].onmouseover=function(){
clearInterval(timer);
changeOption(this.id);
}
lis[i].onmouseout=function(){
timer=setInterval(autoPlay,2000);
}
}
if(timer){
clearInterval(timer);
timer=null;
}
timer=setInterval(autoPlay,2000);
function autoPlay(){
index++;
if(index>=lis.length){
index=0;
}
changeOption(index);
}
function changeOption(curIndex){
for(var j=0;j<lis.length;j++){
lis[j].style.opacity='0.4';
imgs[j].style.display='none';
}
lis[curIndex].style.opacity='0.9';
imgs[curIndex].style.display='block';
index=curIndex;
}
}
function (){
showTime();
}
function checkTime(z){
if(z<10){
z="0"+z;
}
return z;
}
function showTime(){
var now=new Date();
var year=now.getFullYear();
var month=now.getMonth()+1;
var date=now.getDate();
var h=now.getHours();
var m=now.getMinutes();
var s=now.getSeconds();
h=checkTime(h);
m=checkTime(m);
s=checkTime(s);
var day=now.getDay()
var weekday=new Array(7);
weekday[0]="星期天"
weekday[1]="星期一"
weekday[2]="星期二"
weekday[3]="星期三"
weekday[4]="星期四"
weekday[5]="星期五"
weekday[6]="星期六"
document.getElementById("show").innerHTML=year+"年"+month+"月"+date+"日"+weekday[day]+h+":"+m+":"+s;
setTimeout(showTime,1000);
}
时间代码显示了以后,焦点新闻图就不动了..不知道是怎么回事,我是新手,这些都是参考的别人的写的 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询