设计学院-ui163 致力于网页标准 网页设计 web标准与ui设计。

click同时触发onclick 和 onmouseout

上一篇上一篇 | 下一篇下一篇发表时间:2007-9-13 19:27:54
<!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();
[本日志由 ui163 于 2007-9-13 19:27:54 编辑]
上一篇上一篇:如何批量消除链接虚线框?
下一篇下一篇:关于DOM事件模型的两件事
文章来自:蓝色理想
收藏到网摘: 收藏到QQ书签
Tags:

版权隐私 ┊ 免责声明  ┊ 友情链接 ┊ 网站地图  ┊ 联系我们

Copyrights©2006 UI163.com All Rights Reserved 2007

 豫ICP备07501346号