社区
JavaScript
帖子详情
Mozilla中,document.onkeydown不起作用
shanghr
2004-09-20 02:05:19
function document.onkeydown()
{
if (event.keyCode==13) {document.getElementById("ImageButton2").click()}
}
Mozilla中,document.onkeydown不起作用,该怎么写,才能生效呢?
...全文
395
4
打赏
收藏
Mozilla中,document.onkeydown不起作用
function document.onkeydown() { if (event.keyCode==13) {document.getElementById("ImageButton2").click()} } Mozilla中,document.onkeydown不起作用,该怎么写,才能生效呢?
复制链接
扫一扫
分享
举报
写回复
配置赞助广告
4 条
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
打赏红包
rootcn
2004-09-20
打赏
举报
回复
captureevent()
wangxiaomax
2004-09-20
打赏
举报
回复
<html>
<head>
<title>Keyboard Event Handler Lab</title>
<style type="text/css">
td {text-align:center}
</style>
<script type="text/javascript">
function init() {
document.onkeydown = showKeyDown;
document.onkeyup = showKeyUp;
document.onkeypress = showKeyPress;
}
function showKeyDown(evt) {
evt = (evt) ? evt : window.event;
document.getElementById("pressKeyCode").innerHTML = 0;
document.getElementById("upKeyCode").innerHTML = 0;
document.getElementById("pressCharCode").innerHTML = 0;
document.getElementById("upCharCode").innerHTML = 0;
restoreModifiers("");
restoreModifiers("Down");
restoreModifiers("Up");
document.getElementById("downKeyCode").innerHTML = evt.keyCode;
if (evt.charCode) {
document.getElementById("downCharCode").innerHTML = evt.charCode;
}
showModifiers("Down", evt);
}
function showKeyUp(evt) {
evt = (evt) ? evt : window.event;
document.getElementById("upKeyCode").innerHTML = evt.keyCode;
if (evt.charCode) {
document.getElementById("upCharCode").innerHTML = evt.charCode;
}
showModifiers("Up", evt);
return false;
}
function showKeyPress(evt) {
evt = (evt) ? evt : window.event;
document.getElementById("pressKeyCode").innerHTML = evt.keyCode;
if (evt.charCode) {
document.getElementById("pressCharCode").innerHTML = evt.charCode;
}
showModifiers("", evt);
return false;
}
function showModifiers(ext, evt) {
restoreModifiers(ext);
if (evt.shiftKey) {
document.getElementById("shift" + ext).style.backgroundColor =
"#ff0000";
}
if (evt.ctrlKey) {
document.getElementById("ctrl" + ext).style.backgroundColor =
"#00ff00";
}
if (evt.altKey) {
document.getElementById("alt" + ext).style.backgroundColor =
"#0000ff";
}
}
function restoreModifiers(ext) {
document.getElementById("shift" + ext).style.backgroundColor =
"#ffffff";
document.getElementById("ctrl" + ext).style.backgroundColor =
"#ffffff";
document.getElementById("alt" + ext).style.backgroundColor =
"#ffffff";
}
</script>
</head>
<body onload="init()">
<h1>Keyboard Event Handler Lab</h1>
<hr />
<form ID=Form1>
<table border="2" cellpadding="2">
<tr>
<th></th>
<th>onKeyDown</th>
<th>onKeyPress</th>
<th>onKeyUp</th>
</tr>
<tr>
<th>Key Codes</th>
<td id="downKeyCode">0</td>
<td id="pressKeyCode">0</td>
<td id="upKeyCode">0</td>
</tr>
<tr>
<th>Char Codes (IE5/Mac; NN6)</th>
<td id="downCharCode">0</td>
<td id="pressCharCode">0</td>
<td id="upCharCode">0</td>
</tr>
<tr>
<th rowspan="3">Modifier Keys</th>
<td><span id="shiftDown">Shift</span></td>
<td><span id="shift">Shift</span></td>
<td><span id="shiftUp">Shift</span></td>
</tr>
<tr>
<td><span id="ctrlDown">Ctrl</span></td>
<td><span id="ctrl">Ctrl</span></td>
<td><span id="ctrlUp">Ctrl</span></td>
</tr>
<tr>
<td><span id="altDown">Alt</span></td>
<td><span id="alt">Alt</span></td>
<td><span id="altUp">Alt</span></td>
</tr>
</table>
</form>
</body>
</html>
wangxiaomax
2004-09-20
打赏
举报
回复
不好意思,我上面说的是错的。
不过下面一段话,我在mozilla中测试通过。
<input name="test" onkeydown="if (event.keyCode==13) {alert('test');}">
不知document应该怎么用?
wangxiaomax
2004-09-20
打赏
举报
回复
document.onkeypress
try
相关推荐
光标控制php表格,javascript实现的使用方向键控制光标在table单元格
中
切换_javascript技巧...
效果截图:html 代码:选择货架号货架一层二层三层四层五层A001A002A003A004A005javascript 代码:var tdnum = 0;var trid = "td";// 键盘事件
document
.on
keydown
= function(event){// 兼容
Mozilla
Firefoxif (null == event) {event = window.event;...
火狐浏览器enter键不跳转登录问题
1.enter键其它浏览器可以登陆,火狐浏览器
不起作用
$("body").
keydown
(function() { if (event.keyCode == "13") {//keyCode=13是回车键 $('#submit').click(); } });2.修改后的代码
document
.on
keydown
=function(ev
Thundbird数据库迁移
如果你在为重装系统而不得不重新配置Thundbird而苦恼时,也许下面的内容会让你欣喜: 怎样管理配置文件
Mozilla
Thunderbird 存放着您所有的个人设置,包括您的邮件、密码和扩展等,这些都在配置文件
中
。配置文件存放在您的硬盘上的配置文件夹
中
。 如果您在使用
Mozilla
Thunderbird
中
遇到问题(例如:在安装扩展以后发生问题,或其余的功能
不起作用
),通常您...
linux RssFile什么含义,RSS 文件扩展名: 它是什么以及如何打开它?
RSS 文件疑难解答 打开 RSS 文件的麻烦
Mozilla
Firefox 未安装如果您尝试加载 RSS 文件,则会收到 “无法打开 RSS 文件” 等消息。 通常情况下,这意味着
Mozilla
Firefox 没有安装在 %%os%% 上。 操作系统不知道如何处理你的 RSS 文件,因此双击加载该文件
不起作用
。 提示:如果您没有安装
Mozilla
Firefox,并且知道有其他程序可以打开...
python提取html的div属性,使用BeautifulSoup提取html div类
我想从下面的HTML
中
获取“8.0”: ==$0"8.0" /10::after我尝试了下面的代码来提取div class='js otelpuani'
中
的'8.0',但它似乎
不起作用
import urllibimport requestsfrom bs4 import BeautifulSoupimport pyodbcheaders = {"user-agent": "
Mozilla
/5.0 ...
发帖
JavaScript
JavaScript
Web 开发 JavaScript
复制链接
扫一扫
8.7w+
社区成员
22.4w+
社区内容
Web 开发 JavaScript
社区管理员
加入社区
获取链接或二维码
帖子事件
创建了帖子
2004-09-20 02:05
社区公告
暂无公告