Chrome 和 Firefox 的 window.close() 方法的替代方法
Alternative to window.close() method for Chrome and Firefox
我想在同一页面上单击关闭按钮时关闭我的 window/tab。
我用了window.close()
方法。它适用于 IE 版本,但不适用于 Firefox 和 Chrome.
我搜索了很多解决方案。请给我一个演示解决方案。
根据MDN
[Window.close()
] is only allowed to be called for windows that were opened by a script using the window.open() method. If the window was not opened by a script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened by script.
所以为了使用这个方法,你必须使用window.open()
方法才能通过window.close()
关闭它。
我想在同一页面上单击关闭按钮时关闭我的 window/tab。
我用了window.close()
方法。它适用于 IE 版本,但不适用于 Firefox 和 Chrome.
我搜索了很多解决方案。请给我一个演示解决方案。
根据MDN
[
Window.close()
] is only allowed to be called for windows that were opened by a script using the window.open() method. If the window was not opened by a script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened by script.
所以为了使用这个方法,你必须使用window.open()
方法才能通过window.close()
关闭它。