<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)?//如果節(jié)點是text.
?targ=targ.parentNode?//把targ的父節(jié)點賦給targ
var?tname
tname=targ.tagName?/*返回targ的標(biāo)簽名給tname變量。*/
alert("You?clicked?on?a"?+tname?+?"element.")
}
</script>