我如何禁用Tab键 [英] how i can disable tab key

查看:134
本文介绍了我如何禁用Tab键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在asp.net表单中禁用tab键

I want disable tab key in a asp.net form

推荐答案

您可以使用类似于我在下面给出的代码片段来捕获Tab键按下,但是这个解决方案在IE中不起作用。

糟糕的是,您必须将此处理程序附加到表单上可以获得焦点的每个控件上。



我必须强烈建议你不要这样做。 tab-key功能就是它的原因,是一种在浏览器中非常一致的默认行为。人们希望tab键能够在Web表单中的元素之间移动它们,为什么要混淆它们呢?



You can capture the tab key press with a code snippet similar to what I give you below, but this solution will NOT work in IE.
The crappy thing is that you'll have to attach this handler to every control on your form that can receive focus.

I must strongly recommend that you do NOT do this. The tab-key functionality is what it is for a reason and is a default behavior that is very consistent across browsers. People expect the tab key to move them between elements in a web form, so why confuse them?


' #textbox')。live(' keydown',function(e){
var keyCode = e.keyCode || e.which;

if (keyCode == 9 ){
e.preventDefault();
// 此处调用自定义函数
}
});
('#textbox').live('keydown', function(e) { var keyCode = e.keyCode || e.which; if (keyCode == 9) { e.preventDefault(); // call custom function here } });


不,你不想这样做,为什么?这是一种滥用,如果我访问过这样的页面,我会感到非常困扰,当发现它不是浏览器故障时,会将您的网站放到我的永不访问列表中。如果您已经拥有或开发了某个网站,请为此提供参考。 :-)



-SA
No, you don't want to do it, why? This is such an abuse that, should I ever visited such page, I would be much troubled, and, when found that it wasn't a browser glitch, would place your site to my "never visit" list. If you already have or develop some site, please give me a reference, for this purpose. :-)

—SA


这篇关于我如何禁用Tab键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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