<html>
<head>
<script type="text/javascript">
function whichElement(e)
{
var targ
if (!e) var e = window.event
if (e.target) targ = e.target
else if (e.srcElement) targ = e.srcElement
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode
var tname
tname=targ.tagName
alert("You clicked on a " + tname + " element.");
if(e.button==1){
alert("1是左键");
}else if(e.button==2){
alert("2是右键");
}
}
</script>
</head>
<body onmouseup="whichElement(event)">
<h2>This is a header</h2>
<p>This is a paragraph</p>
<img border="0" src="http://hi.youkuaiyun.com/attachment/201008/24/0_1282661224lz4V.gif" alt="Ball" height="500" width="1000">
</body>
</html>