您能否在 Windows CE 中关闭子 IE 窗口时强制将焦点集中在调用 IE 窗口上?

发布于 2024-09-28 03:06:33 字数 551 浏览 1 评论 0原文

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

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

通常,我们的应用程序总是在执行操作后关注特定的文本框。当新窗口关闭时,原始窗口不会成为活动窗口,并且我很难弄清楚如何激活窗口并专注于文本框。

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

预先感谢您的帮助。

编辑:如果有人遇到这个问题,事实证明访问window.opener在Windows CE中不可用,除非OEM专门将其包含在他们的操作系统版本中。有关详细信息,请参阅此知识库文章

I have a struts application being used on handheld devices running Windows CE 4.2/5.0.

We needed the functionality of another app in this one, and the solution was to pop up a window to the other app (using window.open()), run the process, and then close the window to return to the original app.

Normally our apps always focus on a specific textbox after an action. When the new window closes, the original window does not become the active window, and I'm having a hard time figuring out how to activate the window and focus on the textbox.

Is there a way to control which window becomes active when it closes and to trigger a focus event on the required field?

Thanks in advance for your help.

EDIT: In case anyone comes across this question, it turns out accessing window.opener is not available in Windows CE unless the OEM specially included it in their version of the OS. See this knowledgebase article for more information.

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

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

发布评论

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

评论(1

海夕 2024-10-05 03:06:33

不确定 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>

您的弹出窗口应关闭,并且应通过调用获得焦点页面,即使它位于后台或顶部有其他一些窗口。

Not sure about Windows CE but with JavaScript you can use window.opener to refer to the parent window from within a popup. I wrote a little example to demonstrate. Hope it will be of help to you:

Save this as parent.html file:

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

and this as 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>

Your popup should close and focus should be gained by the calling page, even if it is in the background or there is some other windows on top.

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