一个网页中出现连个JS window.onload冲突了,附上代码,请大家给看看如何解决冲突问题
想在一个网页中添加个JS幻灯片脚本,原网页中有个客服脚本也有个JSwindow.onload,添加幻灯片脚本后不能正常运行。只附上window.onload段代码,字数超...
想在一个网页中添加个JS幻灯片脚本,原网页中有个客服脚本也有个JS window.onload,添加幻灯片脚本后不能正常运行。只附上window.onload段代码,字数超。
JS幻灯片JS代码:
window.onload = function()
{
var oDiv = document.getElementById('playBox');
var oPre = getByClass(oDiv,'pre')[0];
var oNext = getByClass(oDiv,'next')[0];
var oUlBig = getByClass(oDiv,'oUlplay')[0];
var aBigLi = oUlBig.getElementsByTagName('li');
var oDivSmall = getByClass(oDiv,'smalltitle')[0]
var aLiSmall = oDivSmall.getElementsByTagName('li');
function tab()
{
for(var i=0; i<aLiSmall.length; i++)
{
aLiSmall[i].className = '';
}
aLiSmall[now].className = 'thistitle'
startMove(oUlBig,'left',-(now*aBigLi[0].offsetWidth))
}
var now = 0;
for(var i=0; i<aLiSmall.length; i++)
{
aLiSmall[i].index = i;
aLiSmall[i].onclick = function()
{
now = this.index;
tab();
}
}
oPre.onclick = function()
{
now--
if(now ==-1)
{
now = aBigLi.length;
}
tab();
}
oNext.onclick = function()
{
now++
if(now ==aBigLi.length)
{
now = 0;
}
tab();
}
var timer = setInterval(oNext.onclick,3000) //滚动间隔时间设置
oDiv.onmouseover = function()
{
clearInterval(timer)
}
oDiv.onmouseout = function()
{
timer = setInterval(oNext.onclick,3000) //滚动间隔时间设置
}
}
客服JS代码:
window.onload=function (){
celive
('cleft_box',100,{$_clear})
} 展开
JS幻灯片JS代码:
window.onload = function()
{
var oDiv = document.getElementById('playBox');
var oPre = getByClass(oDiv,'pre')[0];
var oNext = getByClass(oDiv,'next')[0];
var oUlBig = getByClass(oDiv,'oUlplay')[0];
var aBigLi = oUlBig.getElementsByTagName('li');
var oDivSmall = getByClass(oDiv,'smalltitle')[0]
var aLiSmall = oDivSmall.getElementsByTagName('li');
function tab()
{
for(var i=0; i<aLiSmall.length; i++)
{
aLiSmall[i].className = '';
}
aLiSmall[now].className = 'thistitle'
startMove(oUlBig,'left',-(now*aBigLi[0].offsetWidth))
}
var now = 0;
for(var i=0; i<aLiSmall.length; i++)
{
aLiSmall[i].index = i;
aLiSmall[i].onclick = function()
{
now = this.index;
tab();
}
}
oPre.onclick = function()
{
now--
if(now ==-1)
{
now = aBigLi.length;
}
tab();
}
oNext.onclick = function()
{
now++
if(now ==aBigLi.length)
{
now = 0;
}
tab();
}
var timer = setInterval(oNext.onclick,3000) //滚动间隔时间设置
oDiv.onmouseover = function()
{
clearInterval(timer)
}
oDiv.onmouseout = function()
{
timer = setInterval(oNext.onclick,3000) //滚动间隔时间设置
}
}
客服JS代码:
window.onload=function (){
celive
('cleft_box',100,{$_clear})
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询