有没有办法检测 IE10 的“大写锁定已打开”?特征?
您可能知道,有一种相对简单的方法或多或少可靠地检测 Caps Lock 是否打开,尤其是当用户开始在密码字段中输入时。然而,一个相当未知的事实是,IE10 自动支持此功能,无需任何额外的编码 (来源,屏幕截图的直接链接和一个简单的演示)。因此,现在我面临一个问题,因为如果我添加类似的 Javascript 功能,IE10 用户将看到两个带有警告的“气泡”,一个是由我的脚本创建的,另一个是由他们的浏览器创建的;这可能看起来很难看,甚至令人困惑。这就是为什么我正在寻找一种解决方案,如何检测浏览器是否内置此功能;我希望它触发一些事件或改变一些属性,但我还没有发现这样的事情。
我可能只是在用户代理字符串中查找 Trident/6.0
,但我宁愿避免浏览器检测;如果其他浏览器添加类似的功能,它可能还需要一些代码维护。
如果没有可靠的解决方案,我会要求 IE 团队添加“大写锁定功能”检测功能,并且可能还会要求 HTML 规范的编辑者要求供应商这样做。
As you probably know, there is a relatively simple way how to, more or less reliably, detect whether Caps Lock is on, especially when user starts typing into password fields. However, it is a quite unknown fact that IE10 supports this feature automatically, without need for any additional coding (source, direct link to screenshot and a simple demo). Thus, now I'm facing a problem because if I add a similar Javascript funcionality, IE10 users will see two "bubbles" with the warning, one created by my script and one created by their browser; this might look ugly or even be confusing. This is why I'm looking for a solution how to detect whether browser has this functionality built-in or not; I hope it triggers some event or changes some property, but I haven't found anything like this.
I might just look for Trident/6.0
in user agent string, but I'd rather like to avoid browser detection; it would probably also require some code maintenance if other browsers add similar feature.
If there is no reliable solution, I'll ask the IE Team to add the ability of "caps-lock-is-on feature" detection and probably also the editors of HTML specification to require vendors to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过检查
document
本身的msCapsLockWarningOff
属性值来确定 IE 是否会显示自己的大写锁定警告。此外,您可以打开和关闭此功能:小提琴: http://jsfiddle.net/jonathansampson/mqcHA/ 1/
MSDN:msCapsLockWarningOff 属性
You can determine whether IE will be showing its own caps-lock warning by checking the value of the
msCapsLockWarningOff
property on thedocument
itself. Further, you can toggle this on and off:Fiddle: http://jsfiddle.net/jonathansampson/mqcHA/1/
MSDN: msCapsLockWarningOff property
我建议你看看这个教程
http://www.upsdell.com/BrowserNews/res_sniff.htm
您可以尝试一些方法像这样
或javascript版本检测和原型化浏览器版本
您也可以尝试微软定义的脚本来决定IE浏览器版本
http://support.microsoft.com/kb/167820
I suggest you checkout this tutorial
http://www.upsdell.com/BrowserNews/res_sniff.htm
you may try something like this
or javascript version on detecting and prototyping the browser version
you may also try the script defined by microsoft to decide the IE browser version
http://support.microsoft.com/kb/167820
您可以捕获键盘事件并检测按键,但无法确定大写锁定状态。
You can capture the keyboard event and detect the key, but you cannot determine the caps-lock STATE.