0

我尝试了以下方法:

<a href="JavaScript:window.close()" class="close"></a>

但是当我尝试单击时,浏览器窗口不会关闭。事实上,没有任何影响。

  • 我应该使用什么?

  • 此外,这是一个 Rails 应用程序,该站点是使用引导程序构建的。使用 rails 路由(javascript、bootstrap 已经在资产中)关闭此浏览器窗口的更好方法是什么?

4

1 回答 1

2

Did you open the window you're trying to close with window.open()? You're not allowed to arbitrarily close windows using JavaScript - that would get very annoying, very quickly. Your script can only close a window that it opened itself, or the current window if that was opened by another script.

See also: window.close.

于 2013-04-17T10:51:54.683 回答