同一个网页中俩个js特效对onmouseover 事件冲突 应该改怎么调试 谢谢各位师傅

function$(id){returndocument.getElementById(id);}functionaddLoadEvent(func){varoldonl... function $(id) { return document.getElementById(id); }
function addLoadEvent(func){
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function (){
oldonload();
func();
}
}
}
function moveElement(elementID,final_x,final_y,interval) {
if (!document.getElementById) return false;
if (!document.getElementById(elementID)) return false;
var elem = document.getElementById(elementID);
if (elem.movement) {
clearTimeout(elem.movement);
}
if (!elem.style.left) {
elem.style.left = "0px";
}
if (!elem.style.top) {
elem.style.top = "0px";
}
var xpos = parseInt(elem.style.left);
var ypos = parseInt(elem.style.top);
if (xpos == final_x && ypos == final_y) {
return true;
}
if (xpos < final_x) {
var dist = Math.ceil((final_x - xpos)/10);
xpos = xpos + dist;
}
if (xpos > final_x) {
var dist = Math.ceil((xpos - final_x)/10);
xpos = xpos - dist;
}
if (ypos < final_y) {
var dist = Math.ceil((final_y - ypos)/10);
ypos = ypos + dist;
}
if (ypos > final_y) {
var dist = Math.ceil((ypos - final_y)/10);
ypos = ypos - dist;
}
elem.style.left = xpos + "px";
elem.style.top = ypos + "px";
var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")";
elem.movement = setTimeout(repeat,interval);
}
function classNormal(iFocusBtnID,iFocusTxID){
var iFocusBtns= $(iFocusBtnID).getElementsByTagName('li');
var iFocusTxs = $(iFocusTxID).getElementsByTagName('li');
for(var i=0; i<iFocusBtns.length; i++) {
iFocusBtns[i].className='normal';
代码2
window.onload = function gun()
{
var oBox = document.getElementById("box");
var aUl = document.getElementsByTagName("dl");
var aImg = aUl[0].getElementsByTagName("dt");
var aNum = aUl[1].getElementsByTagName("dt");
var timer = play = null;
var i = index = 0;
//切换按钮
for (i = 0; i < aNum.length; i++)
{
aNum[i].index = i;
aNum[i].onmouseover = function gun()
{
show(this.index)
}
}
//鼠标划过关闭定时器
oBox.onmouseover = function gun()
{
clearInterval(play)
};
//鼠标离开启动自动播放
oBox.onmouseout = function gun()
{
autoPlay()
};
//自动播放函数
function autoPlay ()
{
play = setInterval(function gun() {
index++;
index >= aImg.length && (index = 0);
show(index);
},5000);
}
autoPlay();//应用
//图片切换, 淡入淡出效果
function show (a)
{
index = a;
var alpha = 0;
for (i = 0; i < aNum.length; i++)aNum[i].className = "";
aNum[index].className = "sp-currentt";
clearInterval(timer);
for (i = 0; i < aImg.length; i++)
{
aImg[i].style.opacity = 0;
aImg[i].style.filter = "alpha(opacity=0)";
}
timer = setInterval(function gun() {
alpha += 2;
alpha > 100 && (alpha =100);
aImg[index].style.opacity = alpha / 100;
aImg[index].style.filter = "alpha(opacity = " + alpha + ")";
alpha == 100 && clearInterval(timer)
},20);
}
};
</script>
展开
 我来答
mr19830707
2012-11-27 · TA获得超过209个赞
知道小有建树答主
回答量:201
采纳率:0%
帮助的人:197万
展开全部
把 xx.onmouseover=function xx(){}
换成 (非ie)xx.addEventListener('mouseover', function() {});
(ie) xx.attachEvent('mouseover', function(){});

就不会冲突了.
chenliang_LBS
2012-11-23 · 超过10用户采纳过TA的回答
知道答主
回答量:54
采纳率:0%
帮助的人:27.9万
展开全部
看看“js事件冒泡”可能对你有帮助,没看你代码,太长了。。。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式