简体   繁体   English

javascript window.close() 不起作用

[英]The javascript window.close() does not work

I have page that open a new window.我的页面打开了一个新的 window。 On this window there is close button.在这个 window 上有关闭按钮。 The close button works fine.关闭按钮工作正常。

<input type="button" onClick="javascript:window.close()" value="Close Window" class="uportal-button" style="position: absolute; right: 3px; top: 5px; z-index: 1;">

On this page, I have a html form and Save button.在这个页面上,我有一个 html 表单和保存按钮。 If you save the page and then click "close".如果您保存页面,然后单击“关闭”。 The close button does not work.关闭按钮不起作用。

Any suggestions on how to fix this.对于如何解决这个问题,有任何的建议吗。 I tried suggestions from window.close and self.close do not close the window in Chrome article but did not work我尝试了window.close 和 self.close 的建议不要关闭 Chrome 文章中的 window但没有奏效

The Window.close() method closes the current window, or the window on which it was called. Window.close()方法关闭当前的 window 或调用它的 window。

This method can only be called on windows that were opened by a script using the Window.open() method.此方法只能在由脚本使用Window.open()方法打开的 windows 上调用。 If the window was not opened by a script, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.如果window不是被脚本打开的,控制台会出现类似这样的错误:Scripts may not close windows that were not open by script。

See documentation here for more details.有关更多详细信息,请参阅 此处的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM