简体   繁体   中英

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. Perhaps you should provide a "close" button.

Also, investigate the various libraries such as Boostrap modal popups . They already have worked on the UX issues.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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