Uli*_*Uli 5 javascript internet-explorer keyboard-events
可能的重复:
jQuery 的转义键的键码
这段小代码对 Firefox 和 Opera 来说就像一个魅力。Internet Explorer 不喜欢它。
window.document.onkeydown = function (e) {
if (!e) {
e = event;
}
if (e.keyCode == 27) {
myfunction();
}
}
Run Code Online (Sandbox Code Playgroud)
IE 中不能检测 ESC 的按键吗?谢谢
您使用的是哪个版本的 IE?此代码适用于 IE (9.01):
<!doctype html>
<html>
<head>
<title></title>
<script type="text/javascript">
window.document.onkeydown = function (e)
{
if (!e) e = event;
if (e.keyCode == 27)
alert("Hello!");
}
</script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
还要检查您的 Doctype,您的 IE 可能会使用 Quirks 模式。
| 归档时间: |
|
| 查看次数: |
6424 次 |
| 最近记录: |