JavaScript:检查窗口是否存在 &&已/未最小化

发布于 2024-11-27 23:22:01 字数 250 浏览 5 评论 0原文

我想确保之前打开的任何弹出窗口不仅存在,而且没有最小化。 早期讨论 讨论了检查窗口是否存在。我猜测(希望!)将焦点放在已经打开的窗口上将恢复该窗口(如果它已最小化)。

是这样,还是不是?

谢谢!

I want to be sure that any popup opened earlier not only exists, but is not minimized. An earlier discussion talked about checking for the window's existence. I'm guessing (hoping!) that giving focus to an already-open window will restore that window if it's been minimized.

Is that the case, or no?

Thanks!

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

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

发布评论

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

评论(1

樱娆 2024-12-04 23:22:01

您可以同时执行这两种操作,假设“窗口”是您对选项卡或浏览器窗口的引用,并检测焦点并使用以下命令进行设置:

function detectFocus(state){
   return "Window is now "+state;
}
window.onfocus = function("in focus")
window.onblur = function("not in focus")
/*You then can set state with this method of window:*/
if(needToRestore==true){window.focus}

You can do both, assuming 'window' is your reference to the tab or browser window you and detect focus and set it using these:

function detectFocus(state){
   return "Window is now "+state;
}
window.onfocus = function("in focus")
window.onblur = function("not in focus")
/*You then can set state with this method of window:*/
if(needToRestore==true){window.focus}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文