代码之家  ›  专栏  ›  技术社区  ›  IronicMuffin

你能在Windows CE中的儿童IE窗口关闭时强制将焦点放在呼叫IE窗口上吗?

  •  0
  • IronicMuffin  · 技术社区  · 14 年前

    我有一个struts应用程序正在运行Windows CE 4.2/5.0的手持设备上使用。

    我们需要此应用中另一个应用程序的功能,解决方案是弹出另一个应用程序的窗口(使用window.open()),运行进程,然后关闭该窗口以返回原始应用程序。

    通常情况下,我们的应用程序在一个操作之后总是关注一个特定的文本框。当新窗口关闭时,原始窗口不会变为活动窗口,我很难弄清楚如何激活窗口并关注文本框。

    是否有方法控制哪个窗口在关闭时变为活动状态,并在所需字段上触发焦点事件?

    编辑:如果有人遇到这个问题 开窗器 在Windows CE中不可用,除非OEM特别将其包含在其操作系统版本中。见 this knowledgebase article 更多信息。

    1 回复  |  直到 13 年前
        1
  •  1
  •   user159088 user159088    14 年前

    不确定Windows CE,但可以使用JavaScript window.opener

    将此另存为 parent.html 文件:

    <html>
    <head>
    <script type="text/javascript">
        function openPopup() {
            window.open("child.html", "", "dependent=yes,directories=no,height=400px,width=600px,menubar=no,resizable=yes,scrollbars=yes,status=yes,title=yes,toolbar=no");
        }
    </script>
    </head>
    <body>
    <input type="text" name="txt" id="txtId" value="blah" />
    <input type="button" name="btn" value="Open popup" onclick="openPopup();" />
    </body>
    </html>
    

    而这个 child.html :

    <html>
    <head>
    <script type="text/javascript">
        function goToParent() {
            window.opener.focus();
            window.opener.document.getElementById("txtId").focus();
            window.close();
        }
    </script>
    </head>
    <body>
    Push the button to close this window and focus on the parent's textbox<br />
    <input type="button" name="btn2" value="Close popup" onclick="goToParent();" />
    </body>
    </html>
    

    你的弹出窗口应该关闭,焦点应该通过调用页获得,即使它是在后台或上面有一些其他窗口。