日期:2014-05-16  浏览次数:20356 次

0000event兼容问题0000
我想判断鼠标点击返回的标签
在ie与火狐兼容
谢谢大家伙

ie:window.event.scrElement.nodeName
火狐怎么写?

------解决方案--------------------
<!DOCTYPE HTML>
<html>
<head>
<meta charset="gb2312" />
<title></title>
</head>
<body>
<div id="a">点击</div>
<script>
function $(el){
return typeof el == 'string' ? document.getElementById(el) : el;
}
$('a').onclick = function(e){
e = e || window.event;
var t = e.target || e.srcElement;
alert( t.tagName );
}
</script>
</body>
</html>

------解决方案--------------------
点击的代码要传参数event,如onclick="xx(event)"