function document.onclick()
{
   alert("控件名 : "+ window.event.srcElement.name);
}

解决方案 »

  1.   

    我说的是键盘上的按键,根据不同的按键做不同的处理
    我把你的代码该成:
    function document.onkeypress()
    {
       alert("控件名 : "+ window.event.srcElement.name);
    }
    弹出的alert对话框不能显示我按的键,为空。
      

  2.   

    <script>
    function document.onkeypress()
    {
       alert("按键 : "+ window.event.keyCode);
    }
    </script>
      

  3.   

    <script>
    function document.onkeypress()
    {
       alert("按键 : "+ String.fromCharCode(window.event.keyCode));
    }
    </script>
      

  4.   

    function document.onkeydown()
    {
       alert("键值 : "+ window.event.keyCode);
    }