<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Dynamically Filling Lists</title></head><body onload='document.getELementsByName("txtParentID")[0].value=1'>
<table width="200" border="1">
<tr>
<td>1
<input type="checkbox" name="checkbox1" value="j" /></td>
<td>j</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>2
<input type="checkbox" name="checkbox2" value="p" /></td>
<td>p</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>3
<input name="checkbox3" type="checkbox" value="p" /></td>
<td>p</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>4
<input type="checkbox" name="checkbox4" value="j" /></td>
<td>j</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>5
<input type="checkbox" name="checkbox5" value="p" /></td>
<td>p</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>6
<input type="checkbox" name="checkbox6" value="j" /></td>
<td>j</td>
<td>&nbsp;</td>
</tr>
</table><script language="javascript">
document.onkeydown=function(){
alert(window.event.keyCode)
if(window.event.keyCode==27){
alert("ok")
}else{
alert("err")
}
}
 
</script></form></body>
</html>

解决方案 »

  1.   

    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>按ESC键弹出对话框</title>
    <script type="text/javascript">
    function keyPressHandler(event)
    {
      var e=window.event||event;
      var kC=e.keyCode;
      if(kC==27) alert('You have pressed the esc key!');
    }
    </script>
    </head><body onkeydown="keyPressHandler(event)">
    <h1> Press the escape key </h1>
    </body></html>
      

  2.   

    firefox下,要如何才能正常工作呢
      

  3.   

    忘了写一下,不在<body>标签中加东西
      

  4.   

    我上面写的就可以在FF里正常工作了。如果不在body里加的话,这样写:
    <html><head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>按ESC键弹出对话框</title>
    <script type="text/javascript">
    document.onkeydown=keyPressHandler;
    function keyPressHandler(event)
    {
      var e=window.event||event;
      var kC=e.keyCode;
      if(kC==27) alert('You have pressed the esc key!');
    }
    </script>
    </head><body>
    <h1> Press the escape key </h1>
    </body></html>