[問題] 擷取鍵盤輸入字元
你好:
我撰寫以下程式來顯示出使用者在textbox中所按的字元碼
Textbox1.Attributes.Add("onkeypress", "check(event);");
--------------------------------------------------------
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TT" runat="server"
onkeypress="check(event)"></asp:TextBox>
</form>
</body>
</html>
<script type="text/javascript" >
function check(e) {
var keyCode = (window.event) ? e.which:e.KeyCode;
alert(keyCode);
}
</script>
問題: 如果我在 google chrome執行的話 可以正確顯示出字元碼(十進位)
但如果我在 IE 8 上執行的話 為什麼都跳出 undefined 呢?
是IE 8不支援嗎? 謝謝~
環境: windows xp , visual studio 2008 sp1
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.195.24.18
→
12/22 23:52, , 1F
12/22 23:52, 1F
→
12/23 00:20, , 2F
12/23 00:20, 2F
→
12/23 10:16, , 3F
12/23 10:16, 3F
→
12/23 10:17, , 4F
12/23 10:17, 4F
→
12/23 10:17, , 5F
12/23 10:17, 5F
→
12/23 10:40, , 6F
12/23 10:40, 6F
→
12/23 21:11, , 7F
12/23 21:11, 7F