gpt4 book ai didi

java - 在 Windows CE 中,可以在关闭子 IE 窗口时强制将焦点集中在调用 IE 窗口上吗?

转载 作者:行者123 更新时间:2023-12-01 16:00:52 24 4
gpt4 key购买 nike

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

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

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

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

预先感谢您的帮助。

编辑:如果有人遇到这个问题,事实证明访问window.opener在Windows CE中不可用,除非OEM专门将其包含在他们的操作系统版本中。请参阅this knowledgebase article了解更多信息。

最佳答案

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

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

关于java - 在 Windows CE 中,可以在关闭子 IE 窗口时强制将焦点集中在调用 IE 窗口上吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3969150/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com