English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Window close() method

JavaScript Window Object

close()The function of the method is: close the current window or call the window that opened it.

Only allowed to usewindow.open()The method is called by the window opened by the script.

Syntax:

window.close()
var popupWindow;
// Function to open a new window
function windowOpen() {
  popupWindow = window.open("https://www.oldtoolbag.com", "_blank");
}
// Function to close the opened window
function windowClose() {
  if (popupWindow) {
 popupWindow.close();
  }
}
Test See </›

Browser Compatibility

All browsers fully support the close() method:

Method
close()YesYesYesYesYes

Technical Details

Return Value:None

Related References

Window (Window) Reference:open() Method

Window (Window) Reference:closed() property

JavaScript Window Object