两个js冲突。我在同页面应用了一个头部自动伸缩图片广告,以及一个带缩略图和文字说明的图片自动轮换广告
分别应用时,各自正常;放在一起轮换图片只能停留在第一副,且缩略图与文字都不显示,现请高手帮忙指点!头部代码如下:varintervalId=null;functionsl...
分别应用时,各自正常;放在一起轮换图片只能停留在第一副,且缩略图与文字都不显示,现请高手帮忙指点!头部代码如下:
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
this.stayTime=nStayTime*1000 || 3000;
this.maxHeigth=nMaxHth || 330;
this.minHeigth=nMinHth || 2.5;
this.state=sState || "down" ;
var obj = document.getElementById(id);
if(intervalId != null)window.clearInterval(intervalId);
function openBox(){
var h = obj.offsetHeight;
obj.style.height = ((this.state == "down") ? (h + 2) : (h - 2))+"px";
if(obj.offsetHeight>this.maxHeigth){
window.clearInterval(intervalId);
intervalId=window.setInterval(closeBox,this.stayTime);
}
if (obj.offsetHeight<this.minHeigth){
window.clearInterval(intervalId);
obj.style.display="none";
}
}
function closeBox(){
slideAd(id,this.stayTime,"up",nMaxHth,nMinHth);
}
intervalId = window.setInterval(openBox,30);
}
轮换代码如下:
/mobile/i.test(navigator.userAgent) && !location.hash && setTimeout(function () {
if (!pageYOffset) window.scrollTo(0, 1);
}, 1000);
$(document).ready(function(){
var options = {
nextButton: true,
prevButton: true,
pauseButton: true,
animateStartingFrameIn: true,
transitionThreshold: 250,
afterLoaded: function(){
$("#nav").fadeIn(100);
$("#nav li:nth-child("+(sequence.settings.startingFrameID)+") img").addClass("active");
},
beforeNextFrameAnimatesIn: function(){
$("#nav li:not(:nth-child("+(sequence.nextFrameID)+")) img").removeClass("active");
$("#nav li:nth-child("+(sequence.nextFrameID)+") img").addClass("active");
}
};
var sequence = $("#sequence").sequence(options).data("sequence");
$("#nav li").click(function(){
if(!sequence.active){
$(this).children("img").removeClass("active").children("img").addClass("active");
sequence.nextFrameID = $(this).index()+1;
sequence.goTo(sequence.nextFrameID);
}
});
});
希望高智的能详加指点!!! 展开
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
this.stayTime=nStayTime*1000 || 3000;
this.maxHeigth=nMaxHth || 330;
this.minHeigth=nMinHth || 2.5;
this.state=sState || "down" ;
var obj = document.getElementById(id);
if(intervalId != null)window.clearInterval(intervalId);
function openBox(){
var h = obj.offsetHeight;
obj.style.height = ((this.state == "down") ? (h + 2) : (h - 2))+"px";
if(obj.offsetHeight>this.maxHeigth){
window.clearInterval(intervalId);
intervalId=window.setInterval(closeBox,this.stayTime);
}
if (obj.offsetHeight<this.minHeigth){
window.clearInterval(intervalId);
obj.style.display="none";
}
}
function closeBox(){
slideAd(id,this.stayTime,"up",nMaxHth,nMinHth);
}
intervalId = window.setInterval(openBox,30);
}
轮换代码如下:
/mobile/i.test(navigator.userAgent) && !location.hash && setTimeout(function () {
if (!pageYOffset) window.scrollTo(0, 1);
}, 1000);
$(document).ready(function(){
var options = {
nextButton: true,
prevButton: true,
pauseButton: true,
animateStartingFrameIn: true,
transitionThreshold: 250,
afterLoaded: function(){
$("#nav").fadeIn(100);
$("#nav li:nth-child("+(sequence.settings.startingFrameID)+") img").addClass("active");
},
beforeNextFrameAnimatesIn: function(){
$("#nav li:not(:nth-child("+(sequence.nextFrameID)+")) img").removeClass("active");
$("#nav li:nth-child("+(sequence.nextFrameID)+") img").addClass("active");
}
};
var sequence = $("#sequence").sequence(options).data("sequence");
$("#nav li").click(function(){
if(!sequence.active){
$(this).children("img").removeClass("active").children("img").addClass("active");
sequence.nextFrameID = $(this).index()+1;
sequence.goTo(sequence.nextFrameID);
}
});
});
希望高智的能详加指点!!! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询