有没有办法检测 IE10 的“大写锁定已打开”?特征?

发布于 2024-11-28 21:32:20 字数 836 浏览 7 评论 0原文

您可能知道,有一种相对简单的方法或多或少可靠地检测 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

流云如水 2024-12-05 21:32:20

您可以通过检查 document 本身的 msCapsLockWarningOff 属性值来确定 IE 是否会显示自己的大写锁定警告。此外,您可以打开和关闭此功能:

document.msCapsLockWarningOff = true;

小提琴: 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 the document itself. Further, you can toggle this on and off:

document.msCapsLockWarningOff = true;

Fiddle: http://jsfiddle.net/jonathansampson/mqcHA/1/
MSDN: msCapsLockWarningOff property

吃颗糖壮壮胆 2024-12-05 21:32:20

我建议你看看这个教程
http://www.upsdel​​l.com/BrowserNews/res_sniff.htm

您可以尝试一些方法像这样

<!--[if gte IE 10]>
    <script type="text/javascript">
        var isTrulyIE = true;
    </script>
<![endif]-->

或javascript版本检测和原型化浏览器版本

 this.isIE10 = (this.version == "10.0") || (this.ua.indexOf("trident/6") != -1);

您也可以尝试微软定义的脚本来决定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

<!--[if gte IE 10]>
    <script type="text/javascript">
        var isTrulyIE = true;
    </script>
<![endif]-->

or javascript version on detecting and prototyping the browser version

 this.isIE10 = (this.version == "10.0") || (this.ua.indexOf("trident/6") != -1);

you may also try the script defined by microsoft to decide the IE browser version
http://support.microsoft.com/kb/167820

埖埖迣鎅 2024-12-05 21:32:20

您可以捕获键盘事件并检测按键,但无法确定大写锁定状态。

You can capture the keyboard event and detect the key, but you cannot determine the caps-lock STATE.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文