简体   繁体   中英

window.onunload is not working in Samsung Galaxy Tab browser

In my application clicking on a link a child window opens, now when I close the parent window I need to capture window.onunload event of parent window so that I can close child window.

This is working fine in desktop browsers, but not in Samsung Galaxy Tab in built browser.

Can anybody help me on that?

You need to check if window.unload is even supported on that browser. You might want to look at using div overlays instead which you can control.

Due to inconsistencies in browser support, you might consider redundant mechanisms using a shotgun approach:

  • Trap the parent window's hide, unload, and beforeunload events and close the child window. Trap ALL of them! One of them is bound to work.

  • Write a timer in the child window that polls/checks for window.opener and closes itself if the parent no longer exists

The onbeforeunload function isn't implemented by H browser, instead use:

window.onHide callback function

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