0

根据Mozilla,如果没有使用 window.open() 打开窗口,则 window.close() 在 FF 中将不起作用;

我们已经在一个项目中实现了 ExtJS,并使用锚标记和 target='_blank' 打开了一个新窗口/选项卡。在新窗口中,有一个带有 js 代码的关闭按钮:'window.close();'。

根据 mozilla 标准,这段代码根本不应该工作,但奇怪的是它在某些情况下有效,在某些情况下无效。

任何人都可以提供一些提示/建议或解决方法吗?

4

1 回答 1

0

Try:

window.open('', '_self', '');
window.close();

Was having some issues on Chrome for iOS (in other browsers it works just fine). For that call close after a timeout > 300 as stated here

So code should look like:

window.open('', '_self', '');
setTimeout(window.close, 1000);
于 2013-01-13T16:11:35.990 回答