Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I open a new window with window.open() to redirect users to the oauth login page. However, after successful login when the user is redirected back to my app the previous window with the window.open call does not close itself in ios.

On the iPad it would close the wrong window and on the iPhone it wouldn't close the window at all. The code works fine on Android and on desktop versions of Chrome and Firefox.

After much rooting about, I found a fix (posted below). If anyone has any better ideas or root causes, please post here.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
441 views
Welcome To Ask or Share your Answers For Others

1 Answer

After some searching, I found this tweet which posts a workaround - https://twitter.com/#!/gryzzly/statuses/177061204114685952 by @gryzzly

Copied here in full

window.close() doesn't work on iOS after window.open()ing or target="_blank"? do setTimeout(window.close, timeout); where timeout > 300.

This along with removing a .focus() in which I focus on the parent window before closing the new window completely solved the problem for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...