简体   繁体   English

IE8将弹出式浏览器窗口移至后台

[英]IE8 moves popup browser window to background

I need to open the popup dialog and then set focus on an element of a parent window. 我需要打开弹出对话框,然后将焦点设置在父窗口的元素上。 But as soon as the focus is set (after 5 seconds), the popup dialog moves to background (this behavior is reproducible for IE8 only). 但是,一旦设置了焦点(5秒后),弹出对话框就会移至背景(此行为仅可用于IE8再现)。

There is the code to demonstrate this behavior: 有代码来演示此行为:

Parent Page: 父页面:

<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>

Popup Dialog Page (it is empty): 弹出对话框页面(为空):

<h:head>

</h:head>
<h:body>

</h:body>

Is there any workaround for this problem? 有没有解决此问题的方法?

This behavior seems to be "as designed". 此行为似乎是“按设计的”。 After all, you are setting focus to an element outside of the pop up window, so it makes sense that the pop up window gets moved to the background. 毕竟,您将焦点设置在弹出窗口之外的元素上,因此将弹出窗口移至背景是有意义的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM