click同时触发onclick 和 onmouseout
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload = function(){
var obj = document.getElementById("obj");
obj.onclick = function(){
alert("click");
}
obj.onmouseout = function(){
alert("out");
}
obj.onmouseover = function(){
alert("over");
}
}
</script>
</head>
<body>
<div style="width: 100px; height: 100px; border: 2px solid #000;" id="obj"></div>
</body>
</html>
如题,怎么阻止onmouseout事件呢?
解决方案:
IE停止事件冒泡:
oEvent.cancelBubble = true;
FF停止事件冒泡:
oEvent.stopPropagation();
IE阻止某个事件的默认行为:
oEvent.returnValue = false;
FF阻止某个事件的默认行为:
oEvent.preventDefault();
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript">
window.onload = function(){
var obj = document.getElementById("obj");
obj.onclick = function(){
alert("click");
}
obj.onmouseout = function(){
alert("out");
}
obj.onmouseover = function(){
alert("over");
}
}
</script>
</head>
<body>
<div style="width: 100px; height: 100px; border: 2px solid #000;" id="obj"></div>
</body>
</html>
如题,怎么阻止onmouseout事件呢?
解决方案:
IE停止事件冒泡:
oEvent.cancelBubble = true;
FF停止事件冒泡:
oEvent.stopPropagation();
IE阻止某个事件的默认行为:
oEvent.returnValue = false;
FF阻止某个事件的默认行为:
oEvent.preventDefault();
[本日志由 ui163 于 2007-9-13 19:27:54 编辑]
上一篇:如何批量消除链接虚线框?
下一篇:关于DOM事件模型的两件事
文章来自:蓝色理想
收藏到网摘:
收藏到QQ书签
Tags:
上一篇:如何批量消除链接虚线框?
下一篇:关于DOM事件模型的两件事
文章来自:蓝色理想
收藏到网摘:
收藏到QQ书签
Tags:

