javascript - IE8 将弹出浏览器窗口移至背景

标签 javascript html internet-explorer-8

我需要打开弹出对话框,然后将焦点设置在父窗口的元素上。但一旦设置焦点(5 秒后),弹出对话框就会移至背景(此行为仅可在 IE8 中重现)。

有代码可以演示此行为:

父页面:

<h:head>
    <h:outputScript name="jquery.js"/>
    <script type="text/javascript">
        var showPopup = function () {
            window.open("http://localhost:8880/pages/reader.xhtml", "Popup");
        };

        var setupFocus = function () {
            setTimeout(function () {
                $('#mainFrm\\:nameInp').focus();
            }, 5000);
        };
    </script>
</h:head>
<h:body>
    <h:form id="mainFrm">
        <h:inputText id="nameInp"/>
        <h:commandButton type="button" onclick="showPopup(); setupFocus()" value="Show Popup"/>
    </h:form>
</h:body>

弹出对话框页面(为空):

<h:head>

</h:head>
<h:body>

</h:body>

这个问题有解决办法吗?

最佳答案

这种行为似乎是“按照设计的”。毕竟,您将焦点设置到弹出窗口之外的元素,因此将弹出窗口移动到背景是有意义的。

关于javascript - IE8 将弹出浏览器窗口移至背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24140569/

相关文章:

html - Rails 命名空间路由问题

javascript - Internet Explorer 8 的 CSS 故障排除

javascript - 即使触发了许多动画,也显示动画完成一次

javascript - JS 中的 "this"关键字 - 我很困惑

javascript - 如何绑定(bind)onclick事件来调用函数

javascript - 如何使部分透明的 .png 下方的 <div> 保持可滚动?

javascript - AngularJS包含模板不运行主JavaScript

html - 使用 Button 的响应式文本固定定位

css - 过滤器和背景图像在一起

html - IE8 按钮的 CSS "initial"值