iPad Safari IOS 5 window.close() closing wrong window

前端 未结 3 1352
傲寒
傲寒 2021-01-12 02:23

We have an iPad application that\'s working on our older iPads.

We open external links using var x = window.open(url)

at the end of the day, when the user cl

相关标签:
3条回答
  • 2021-01-12 02:45

    That did the trick for me (iPad 2 and 3; 3 with iOS 5.1.1)

    var host=window.opener;
    window.focus(); /* solves the iPad3 problem */
    window.close(); /* the actual closing we want to achieve... */
    /* makes the focus go back to opener on iPad2, fails silently on iPad3 */
    try { host.focus(); } catch(e) {} 
    
    0 讨论(0)
  • 2021-01-12 02:57

    I had the same issue as well. My initial code would focus on the parent window and then close the current one. This always ends up closing the wrong window. What I did was to remove the .focus call and added a small delay to the window.close() and it worked for me. Original source for the delay suggestion - https://twitter.com/#!/gryzzly/statuses/177061204114685952

    0 讨论(0)
  • 2021-01-12 03:01

    Set focus on the window before closing it

    0 讨论(0)
提交回复
热议问题