在console中弹出提示”Scripts may close only the windows that were opened by it” (脚本只能关闭它所打开的窗口),[如下图所示] , 不明白是什么原因。
非弹出窗口，即是指（opener=null 及 非window.open()打开的窗口,比如URL直接输入的浏览器窗体， 或由其它程序调用产生的浏览器窗口）。
由 https://developer.mozilla.org/en-US/docs/Web/API/window.close 可知:
Closes the current window, or the window on which it was called.
When this method is called, the referenced
window is closed.
This method is only allowed to be called for windows that were opened by a script using the
Scripts may not close windows that were not opened by script.
Closing a window opened with
This example demonstrates how to use this method to close a window opened by script calling
Closing the current window
When you call the
close() method directly, rather than calling
close() on a
windowinstance, the browser will close the frontmost window, whether your script created that window or not.
在某些实际应用中，window.close() and self.close() 是不能关闭非弹出窗口（opener=null及非window.open()打开的窗口）。