同一个页面两处js冲突了,请高手指点,谢谢!

乱世骄子 乱世骄子 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

第一个js是控制绿框里面鼠标滑过小图上面大图跟着变化,第二个js控制 右上角在线客服,鼠标滑过展开的,现在在线客服好用也就是第二个js好用

第一个js 控制鼠标滑过小图切换到相应大图

<script language="javascript" type="text/javascript">
/**/
var browse = window.navigator.appName.toLowerCase();
var MyMar;
var speed = 1; //速度,越大越慢
var spec = 1; //每次滚动的间距, 越大滚动越快
var minOpa = 100; //滤镜最小值
var maxOpa = 100; //滤镜最大值
var spa = 2; //缩略图区域补充数值
var w = 0;
spec = (browse.indexOf("microsoft") > -1) ? spec : ((browse.indexOf("opera") > -1) ? spec*10 : spec*20);
function $(e) {return document.getElementById(e);}
function goleft() {$('photos').scrollLeft -= spec;}
function goright() {$('photos').scrollLeft += spec;}
function setOpacity(e, n) {
if (browse.indexOf("microsoft") > -1) e.style.filter = 'alpha(opacity=' + n + ')';
else e.style.opacity = n/100;
}
$('goleft').style.cursor = 'pointer';
$('goright').style.cursor = 'pointer';
$('mainphoto').onmouseover = function() {setOpacity(this, maxOpa);}
$('mainphoto').onmouseout = function() {setOpacity(this, maxOpa);}
//$('mainphoto').onclick = function() {location = this.getAttribute('name');}
$('goleft').onmouseover = function() {this.src = 'images/goleft2.gif'; MyMar=setInterval(goleft, speed);}
$('goleft').onmouseout = function() {this.src = 'images/goleft.gif'; clearInterval(MyMar);}
$('goright').onmouseover = function() {this.src = 'images/goright2.gif'; MyMar=setInterval(goright,speed);}
$('goright').onmouseout = function() {this.src = 'images/goright.gif'; clearInterval(MyMar);}
window.onload = function() {
setOpacity($('mainphoto'), minOpa);
var rHtml = '';
var p = $('showArea').getElementsByTagName('img');
for (var i=0; i<p.length; i++) {
w += parseInt(p[i].getAttribute('width')) + spa;
setOpacity(p[i], minOpa);
//p[i].onclick = function() {location = this.getAttribute('name');}
p[i].onmouseover = function() {
setOpacity(this, maxOpa);
$('mainphoto').src = this.getAttribute('rel');
$('mainphoto').setAttribute('name', this.getAttribute('name'));
setOpacity($('mainphoto'), maxOpa);
}
p[i].onmouseout = function() {
setOpacity(this, minOpa);
setOpacity($('mainphoto'), minOpa);
}
rHtml += '<img src="' + p[i].getAttribute('rel') + '" width="0" height="0" alt="" />';
}
$('showArea').style.width = parseInt(w) + 'px';
var rLoad = document.createElement("div");
$('photos').appendChild(rLoad);
rLoad.style.width = "1px";
rLoad.style.height = "1px";
rLoad.style.overflow = "hidden";
rLoad.innerHTML = rHtml;
}
</script>

第二个 js 控制右上角在线客服,鼠标滑过展开
<script type="text/javascript">
window.onload = window.onresize = window.onscroll = function() {
var oBox = document.getElementById("divQQbox");
var oLine = document.getElementById("divOnline");
var oMenu = document.getElementById("divMenu");
var iScrollTop = document.documentElement.scrollTop || document.body.scrollTop;
setTimeout(function() {
clearInterval(oBox.timer);
var iTop = parseInt((document.documentElement.clientHeight - oBox.offsetHeight) / 5) + iScrollTop;
oBox.timer = setInterval(function() {
var iSpeed = (iTop - oBox.offsetTop) / 2;
iSpeed = iSpeed > 0 ? Math.ceil(iSpeed) : Math.floor(iSpeed);
oBox.offsetTop == iTop ? clearInterval(oBox.timer) : (oBox.style.top = oBox.offsetTop + iSpeed + "px");
}, 20)
}, 100)

oBox.onmouseover = function() {
this.style.width = 190 + "px";
oLine.style.display = "block";
oMenu.style.display = "none";
};
oBox.onmouseout = function() {
this.style.width = '';
oLine.style.display = "none";
oMenu.style.display = "block";
};
};
</script>
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
乱世骄子
JavaScript 87,983 成员 224,681 内容