window.close()在iOS上不起作用 [英] window.close() doesn't work on iOS

查看:1206
本文介绍了window.close()在iOS上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用window.open()打开一个新窗口,将用户重定向到oauth登录页面。但是,在成功登录后,当用户被重定向回我的应用程序时,带有window.open调用的上一个窗口不会在ios中自行关闭。

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.

在iPad上,它会关闭错误的窗口,在iPhone上它根本不会关闭窗口。该代码适用于Android和桌面版Chrome和Firefox。

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.

推荐答案

经过一番搜索,我发现这条推文发布了一个解决方法 - https://twitter.com/#!/gryzzly/statuses/177061204114685952 @gryzzly

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

完全复制


window.open()或$后,window.close()在iOS上不起作用b $ b target =_ blank? do setTimeout(window.close,timeout);其中超时>
300。

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

这还删除 .focus()在关闭新窗口之前我专注于父窗口完全解决了我的问题。

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.

这篇关于window.close()在iOS上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆