event.keyCode = 9选项卡事件在FireFox中不起作用 [英] event.keyCode=9 tab event doesn't work in FireFox

查看:256
本文介绍了event.keyCode = 9选项卡事件在FireFox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用自己的功能调用tab事件时遇到了麻烦。

i呼叫标签事件使用

event.keyCode = 9;

但是firefox给出了这个错误错误:事件没有定义。


怎么办? plz help

I am having trouble in calling tab event using my own function.
i call tab event using
event.keyCode = 9;
but firefox gives this error "Error: event is not defined".

What to do? plz help

推荐答案

要编写IE以外的事件处理脚本,你需要学习DOM事件模型。

google it,或者从这里开始 -

http://www.javascriptkit.com/domref/domevent.shtml
To script event handling beyond IE you need to learn the DOM event model.
google it, or start here-
http://www.javascriptkit.com/domref/domevent.shtml


在firefox中你可以试试这个:

[HTML ]

<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Transitional // EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

< html xmlns =" http://www.w3.org / 1999 / xhtml">

< head>

< meta http-equiv =" Content-Type"含量=" text / html的;字符集= GB2312" />

< title>无标题文档< / title>

< script type =" text / javascript">

function codeNum(e)

{

alert(e.keyCode);

}

< / script>

< / head>


< body>

< input type =" text" onkeydown =" codeNum(event)"

< / body>

< / html>


[/ HTML]
in firefox you can try this:
[HTML]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function codeNum(e)
{
alert(e.keyCode);
}
</script>
</head>

<body>
<input type="text" onkeydown="codeNum(event)"/>
</body>
</html>

[/HTML]


实际上在firefox中它的charCode不是keyCode ... keyCode是IE特定的。
actually in firefox guys its charCode not keyCode... keyCode is IE specific.


这篇关于event.keyCode = 9选项卡事件在FireFox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆