javascript window.close() 在 iOS 8 GM 种子上不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25804730/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 05:03:36  来源:igfitidea点击:

window.close() doesn't work on iOS 8 GM seed

javascriptiossafariios8

提问by lambao

I am trying to open new tab via Javascriptusing window.open(), then using window.close()to close, but it seems window.close()doesn't work in safari( iOS 8 GM seed). Here is the code:

我正在尝试通过Javascript使用打开新标签window.open(),然后使用window.close()关闭,但它似乎window.close()在 safari(iOS 8 GM 种子)中不起作用。这是代码:

A.html:

A.html:

<button onclick="window.open('./B.html'); return false;">Open B</button>

<button onclick="window.open('./B.html'); return false;">Open B</button>

B.html:

B.html:

<button onclick="window.close();">Close</button>

<button onclick="window.close();">Close</button>

I tried several ways like: setTimeout, window.open()then close, but doesn't help.

我尝试了几种方法,例如:setTimeoutwindow.open()然后关闭,但没有帮助。

Is there any workaround for this situation?

这种情况有什么解决方法吗?

采纳答案by Kazutaka Kamiya

There isn't a workaround.

没有解决方法。

I added a message in our web pages. 'Please close this window if it does not close automatically.'

我在我们的网页中添加了一条消息。'如果它没有自动关闭,请关闭这个窗口。'

There is a forum about this issue. https://devforums.apple.com/message/1044445

有一个关于这个问题的论坛。 https://devforums.apple.com/message/1044445