<script language="javascript">
function mouse()
{
    switch(event.type)
{
case "click":
alert("鼠标点击的");
break;
case "keydown":
alert("按下一个键的");
break;
default:
alert("其它事件:" + event.type);
break;
}
}
</script>
<table>
  <tr>
    <td onclick="mouse();" onkeyDown="mouse();" language="JavaScript">测试区域</td>
  </tr>
</table>

解决方案 »

  1.   

    <table>
    <tr>
    <td name=""  onclick="javascript:mouse()"
    onkeyDown="javascript:mouse()">
    </td></td></table>
     
    <script language="javascript">
    function test()
    {
        alert("mouse click"); 最好是在 IE 和 Mozilla 中都可以
    }
    </script>
      

  2.   

    <html>
    <head>
    </head>
    <body>
    <table  border="1" cellspacing="2" cellpadding="2">
    <tr>
    <td></td>
    <td onclick="javascript:test(event)">Mouse click</td>
    <td></td>
    </tr>
    <script language="javascript">
    function test(event)
    {
    if(event.button[1])
    {
    alert("left button click");
    }
    else 
    {
    alert("error");
    }
    }
    </script>
    </body>
    </html>
    不可以啊?????????
      

  3.   

    可以了。
    function key(e)
    {
    var code;
    if(e.keyCode || e.type)
    {
    switch(e.type)
    {
    case "click":
    code=1;
    break;
    case "keydown":
    code=e.keyCode;
    break;
    default:
    break;
    }
    }
    return code;
    }
    但是:<td onclick="javascript:event(event)" onkeydown="javascript:key(event)">Mouse click</td>
    怎么不能得到键盘事件?在td中,如果是在《input》中就可以