简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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