当按住空格并按 Tab 键浏览表单时,Internet Explorer 挂起

发布于 2025-01-06 00:46:25 字数 582 浏览 2 评论 0原文

在按住空格键同时按住空格键浏览表单输入后,Internet Explorer 似乎挂起,

以说明问题我设置了一个带有 3 个复选框的非常简单的表单。 http://inkistudios.com/tests/checkbox.html

如果您按 Tab 键直到出现到复选框输入。 尝试按住空格键,就像使用键盘切换复选框一样。 但然后按 Tab 键切换到另一个复选框,然后释放空格键。 这似乎会导致 Internet Explorer 挂起,您无法拖动窗口,并且单击页面上的任何内容似乎会选中/取消选中您选择的复选框。 所以 Internet Explorer 似乎仍在等待第一个复选框上释放空格键... 我在 Internet Explorer 7、8 和 9 中尝试过此操作,似乎都有相同的结果。

我想知道是否有人有解决方案。 也许一些 JavaScript 会强制浏览器释放它所处的状态?

我已经尝试过取消该元素的焦点或使用 jquery 将焦点放在另一个元素上,以防发生这种情况,但我尝试过的似乎都无法解决该问题。

Internet explorer seems to be hang after you tab through form inputs while holding in spacebar

to illustrate the problem I've setup a really simple form with 3 checkboxes.
http://inkistudios.com/tests/checkbox.html

if you press tab until you get to a checkbox input.
try holding in spacebar as if you would toggle the checkbox using your keyboard.
but then press tab to switch to another checkbox before releasing the spacebar.
this seems to cause Internet explorer to hang , you cannot drag the window around , and clicking on anything on the page seems to check/uncheck the checkbox you tabbed out of.
so Internet Explorer seems to still be waiting for spacebar to be released on the first checkbox...
I tried this in Internet Explorer 7, 8 and 9, all seems to have the same result.

I was wondering if anybody has a solution for this.
maybe some javascript that would force the browser to release the state it is in ?

I've already tried unfocusing the element or putting focus on another element using jquery in case that happens , but nothing I've tried seems to solve it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

忘东忘西忘不掉你 2025-01-13 00:46:25

我能够使用两个版本的 IE 重现此行为:

  • IE 8(版本 8.0.7601.1754)。
  • IE 9(版本 9.0.8112.16421,更新版本 9.0.4)

除了能够单击页面中的任意位置之外,单击窗口的标题栏也会切换复选框。我发现一旦你再次按下空格键,它就会释放窗口。

这看起来像是 IE 处理焦点方式中的一个错误。由于再次按下空格时窗口会立即释放,因此我想也许可以编写 JavaScript 来模拟按下空格键。这是我根据你的测试用例编写的脚本:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="robots" content="none">
    <meta name="viewport" content="width=960">

    <title>checkbox test</title>

</head>
<body>

<h1>Checkbox test</h1>

<input name="item1" id="item1" value="1" checked="checked" type="checkbox" />
<label for="item1">item1</label><br />

<input name="item2" id="item2" value="2" checked="checked" type="checkbox" />
<label for="item2">item2</label><br />

<input name="item3" id="item3" value="3" type="checkbox" />
<label for="item3">item3</label>

<script>
<!--
var spaceDown = false;
var tabDown = false;

window.onload = function(){
    document.onkeydown = function(){
        if(event.keyCode == 32){ spaceDown = true; }
        if(event.keyCode == 9){ tabDown = true; }
    }

    document.onkeyup = function(){
        if(spaceDown && tabDown){
            console.log("Danger, Will Fobinson!");
            console.log("Simulating space bar press ...");
            var e = document.createEventObject();
            e.altKey = false;
            e.ctrlKey = false;
            e.shiftKey = false;
            e.keyCode = 32;

            document.fireEvent("onkeydown", e);
            document.fireEvent("onkeyup", e);
        }

        if(event.keyCode == 32){ spaceDown = false; }
        if(event.keyCode == 9){ tabDown = false; }
    }
}



// -->
</script>

</body>
</html>

不幸的是,当你在 IE 8 中触发危险条件时(聚焦复选框、向下空格键、向下制表符),它会大量增加 IE 的 CPU 使用率,并弹出一个小对话框,显示:

对话框显示:'堆栈溢出位于第 0 行'

所以这不是很有帮助。

正如您所发现的, focus() 和 Blur() 方法在这种情况下似乎也没有做任何有用的事情。

所以基本上,我认为你唯一的选择是将其作为错误报告给 IE 团队,并希望他们修复它。我不确定你实际上是如何做到的。理论上,您可以在 http://connect.microsoft.com/IE 提交 IE 反馈 - 但是您需要使用 Windows Live ID 登录,但我不确定您如何获得其中之一。

除此之外......好吧,我们只是希望不要太多人触发这个错误!

I was able to reproduce this behavior using two versions of IE:

  • IE 8 (version 8.0.7601.1754).
  • IE 9 (version 9.0.8112.16421, update version 9.0.4)

Clicking the title bar of the window toggled the checkbox, in addition to being able to click anywhere in the page. I found that it releases the window as soon as you press space again.

This looks like a bug in how IE handles focus. Since the window releases as soon as space is pressed again, I thought maybe it would be possible to write JavaScript to simulate a space bar press. Here's the script I worked out based on your test case:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="robots" content="none">
    <meta name="viewport" content="width=960">

    <title>checkbox test</title>

</head>
<body>

<h1>Checkbox test</h1>

<input name="item1" id="item1" value="1" checked="checked" type="checkbox" />
<label for="item1">item1</label><br />

<input name="item2" id="item2" value="2" checked="checked" type="checkbox" />
<label for="item2">item2</label><br />

<input name="item3" id="item3" value="3" type="checkbox" />
<label for="item3">item3</label>

<script>
<!--
var spaceDown = false;
var tabDown = false;

window.onload = function(){
    document.onkeydown = function(){
        if(event.keyCode == 32){ spaceDown = true; }
        if(event.keyCode == 9){ tabDown = true; }
    }

    document.onkeyup = function(){
        if(spaceDown && tabDown){
            console.log("Danger, Will Fobinson!");
            console.log("Simulating space bar press ...");
            var e = document.createEventObject();
            e.altKey = false;
            e.ctrlKey = false;
            e.shiftKey = false;
            e.keyCode = 32;

            document.fireEvent("onkeydown", e);
            document.fireEvent("onkeyup", e);
        }

        if(event.keyCode == 32){ spaceDown = false; }
        if(event.keyCode == 9){ tabDown = false; }
    }
}



// -->
</script>

</body>
</html>

Unfortunately, when you trigger the danger condition in IE 8 (focus a checkbox, space down, tab down), it increases IE's CPU usage a LOT and pops up a little dialog box saying:

Dialog box saying: 'stack overflow at line: 0'

So that's not very helpful.

And as you discovered, the focus() and blur() methods don't seem to do anything helpful in this instance either.

So basically, I think your only option is to report it as a bug to the IE team, and hope they fix it. I'm not sure how you do that actually. In theory you can submit IE feedback at http://connect.microsoft.com/IE -- but you'll need to log in with a Windows Live ID, and I'm not sure how you get one of those.

Other than that ... well, let's just hope that not too many people trigger the bug!

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