Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Chrome和Firefox的window.close()方法的替代方法_Javascript_Jquery_Google Chrome_Firefox - Fatal编程技术网

Javascript Chrome和Firefox的window.close()方法的替代方法

Javascript Chrome和Firefox的window.close()方法的替代方法,javascript,jquery,google-chrome,firefox,Javascript,Jquery,Google Chrome,Firefox,我想在同一页面上单击关闭按钮时关闭窗口/选项卡 我使用了window.close()方法。它适用于IE版本,但不适用于Firefox和Chrome 我寻找了很多解决办法。请给我一个演示解决方案。根据 [Window.close()]仅允许对脚本使用Window.open()方法打开的窗口调用。如果窗口不是由脚本打开的,则JavaScript控制台中会出现以下错误:脚本可能无法关闭非由脚本打开的窗口 因此,为了使用此方法,您必须使用window.open()方法才能通过window.close()

我想在同一页面上单击关闭按钮时关闭窗口/选项卡

我使用了
window.close()
方法。它适用于IE版本,但不适用于Firefox和Chrome

我寻找了很多解决办法。请给我一个演示解决方案。

根据

[
Window.close()
]仅允许对脚本使用Window.open()方法打开的窗口调用。如果窗口不是由脚本打开的,则JavaScript控制台中会出现以下错误:脚本可能无法关闭非由脚本打开的窗口

因此,为了使用此方法,您必须使用
window.open()
方法才能通过
window.close()
根据

[
Window.close()
]仅允许对脚本使用Window.open()方法打开的窗口调用。如果窗口不是由脚本打开的,则JavaScript控制台中会出现以下错误:脚本可能无法关闭非由脚本打开的窗口


因此,为了使用此方法,您必须使用
window.open()
方法才能通过
window.close()

关闭它。向我们显示您正在尝试的代码,您说它不工作可能重复的代码向我们显示您正在尝试的代码,您说它不工作可能重复的代码