Window.close()

Window.close()

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English

Always switch to English

Window.close()

Baseline

Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年7月⁩.

Learn more

See full compatibility

Report feedback

Window.close() 方法关闭当前窗口或某个指定的窗口。

该方法只能由 Window.open() 方法打开的窗口的 window 对象来调用。如果一个窗口不是由脚本打开的,那么,在调用该方法时,JavaScript 控制台会出现类似下面的错误:不能使用脚本关闭一个不是由脚本打开的窗口。 或 Scripts may not close windows that were not opened by script. 。

同时也要注意,对于由 HTMLIFrameElement.contentWindow 返回的 Window 对象,close() 也没有效果。

相关推荐

手表厚度选择 手表表盘厚度多少最合适
揭秘《完美国际》神技能:独家攻略,轻松解锁游戏新境界!
6月30日足球赛前比分预测 进球数 半全场 二串一 今日5场竞彩足球赛事赛前分析预测