window.close and self.close do not close the window in Chrome

后端 未结 16 1868
孤城傲影
孤城傲影 2020-11-21 05:48

The issue is that when I invoke window.close() or self.close() it doesn\'t close the window. Now there seems to be a belief that in Chrome you can\

16条回答
  •  忘掉有多难
    2020-11-21 06:11

    Despite thinking it is "patently false", what you say "seems to be a belief" is actually correct. The Mozilla documentation for window.close says

    This method 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

    You say that it is "supposed to still do it" but I don't think you'll find any reference which supports that, maybe you've misremembered something?

提交回复
热议问题