Window close()Method
Window Object
Definition and Usage
The close() method is used to close a browser window.
Syntax
window.close()
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the close() method
Example
Example
The following example can close the new browser window:
function openWin(){
myWindow=window.open("","","width=200,height=100");
myWindow.document.write("<p>This is 'my window'</p>");
}
function closeWin(){
myWindow.close();
}
myWindow=window.open("","","width=200,height=100");
myWindow.document.write("<p>This is 'my window'</p>");
}
function closeWin(){
myWindow.close();
}
Try it Yourself »
Window Object Other Extensions