javascript close window – How to close window using JavaScript?

javascript close window – The close() method closes the current window. also JavaScript provides an in-built function named close() to close the browser window.

javascript close window

window.close();//closes the current browser tab. To close a window or tab that was opened using JavaScript. Windows are opened with; and Windows are closed with window.close();

How to Close a Window with JavaScript?

javascript close current window
closes the current browser tab


javascript close window Example


<!DOCTYPE html>

<button onclick="openWin()">Open "livePayment"</button>
<button onclick="closeWin()">Close "livePayment"</button>

var livePayment;

function openWin() {
  livePayment ="", "livePayment", "width=200,height=100");
  livePayment.document.write("<p>This is 'livePayment'</p>");

function closeWin() {


Example : close a browser window with HTML code

<input type="button" value="Exit" onclick="self.close()">

<script language="javascript" type="text/javascript">
function windowClose() {'','_parent','');

<input type="button" value="Exit" onclick="windowClose();">

Don’t Miss : How To Open URL In New Tab Using JavaScript?

I hope you get an idea about javascript close window.
I would like to have feedback on my
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.