简体   繁体   English

不使用时如何自动关闭弹出窗口?

[英]How To Close Popup Window Automatically When Its Not In Use?

I want a popup window to close automatically as soon as the user minimizes the window. 我希望弹出式窗口在用户最小化窗口后立即自动关闭。 My code is as follows: 我的代码如下:

<a href="#" onclick="Popup=window.open('fb.html','Popup','toolbar=no,location=no,status=yes,menubar=no,scrollbars=no,resizable=no,width=620,height=400,left=230,top=23'); return false;">

any ideas? 有任何想法吗?

See a post about programmatically opening and closing pop-ups. 看到一个帖子关于编程打开和关闭弹出窗口。

For browser windows or tabs, I believe that you need the user to click a confirmation box (the confirmation is created by the browser as a security feature). 对于浏览器窗口或选项卡,我认为您需要用户单击确认框(确认是由浏览器创建的安全功能)。

Added Think about your UX (User Experience) -- it is not usual for a user to think about minimizing a window. 添加了考虑您的UX(用户体验)的想法-用户通常不会考虑最小化窗口。 Perhaps you should provide a "close" button. 也许您应该提供一个“关闭”按钮。

Also, investigate the various libraries such as Boostrap modal popups . 另外,研究各种库,例如Boostrap模态弹出窗口 They already have worked on the UX issues. 他们已经致力于解决UX问题。

There's no event that triggers when the window is minimized. 最小化窗口时不会触发任何事件。 The best you can do is to check the height and width at a set interval. 最好的办法是按设定的时间间隔检查高度和宽度。 Closing the browser window is trivial Popup.close() should do it. 关闭浏览器窗口很简单, Popup.close()应该这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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