文中说的方法记录一下























使用方法












uniconDom[i]是页面的一个html标记
实例二:
<!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>demo</title>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>demo</title>
<meta name="Description" content="网页说明" />
<meta name="Keywords" content="网页关键字" />
<meta name="Robots" content="all" />
<meta name="Author" content="" />
<meta name="Copyright" content=" 版权所有 2009" />
<link href="css/global.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript">
//阻止事件冒泡后,你点击灰色盒子,整个过程只弹一次对话框了(注意与默认情况对比)
function showMsg(obj,evt)
{
alert(obj.id);
var e=(evt)?evt:window.event;
stopBubble(e);
}
//阻止事件冒泡函数
function stopBubble(e)
{
if(window.event){
window.event.cancelBubble=true;
}else{
e.stopPropagation();
}
}
</script>
</head>
<body>
<div id="wrap">
<div onclick="showMsg(this,event)" id="outSide" style="width:100px;
height:100px; color:#fff; background:#000; padding:50px">
outside
<div onclick="showMsg(this,event)" id="inSide" style="width:100px; height:100px; color:red; background:#CCC">
inside
</div>
</div>
</div>
</body>
</html>