showing results for - "how to close tab by javascript"
Christian
16 Feb 2018
1window.close();//closes the current browser tab
Dario
25 Jan 2020
1// IF you use in a button
2<button onclick="window.close();">Exit</button>
3// if you use in function
4function closeWin() {
5  myWindow.close();   // Closes the new window
6}
7// But it will only work when you open a window through your code like this
8function openWin() {
9  myWindow = window.open("", "myWindow", "width=200, height=100");   // Opens a new window
10}
11// You can't close the current window that was open by browser. beacuse browser don't give permission for this
Benjamin
27 Nov 2020
1//You are able to close a browser tab with an index.html page
2//The code below from lines 3-13 are from the index.html page, it redirects you to another page
3<!DOCTYPE html>
4<html>
5<head>
6
7    <script type="text/javascript">
8window.open("/folderDirectory/example.php"); 
9
10
11     </script>
12</head>
13</html>
14//The code below is from the example.php
15  $(document).ready(function(){
16    $("button").click(function(){
17      window.close();
18      });
19  });//jquery is used to make the user click the button to exit 
20
21//The code below should be placed in the html body, it is a button that closes the window when the user clicks on it
22<button style="border: none;" >Exit</button>
23
24
Elena
06 Feb 2017
1Writing this on 24 Dec 2020. Tried almost all the things available on google, but none of them worked in Chrome browser. window.open('','_self').close() works for IE.
queries leading to this page
close a tab javascirpclose a tab from javascriptclose page javascripthow to close web page in javascripttab close event in jsjs to close current tabclose a browser tab from jsclose tab automatically javascriptclose tab using tab name in javascripthow to close current tab using javascriptprevent close tab js js close opened by ahow to close a tab by clicking a button with htmljavascript close current tab chromea tag close windowjavascript script to close other specific tabs or browserjavascript close current windowhow to stop tab event in javascriptclosing tab with jsjavascript exit current tabjs close current windowhow to close window tab using javascriptphp cbutton to close current tabscript to close tabhow to close a tab using javascriptclose browser tab javascriptclose browser in jsjs prevent tab closehtml closing tab 27html close tab eventjavascript close current pagedue you really want to close the current tab javascript codedo something while close tab javascriptjavascript close browser current tabon click close tapevent close tabjavascript close current tab without promptdoes js always run when we close a tabjavascript on close tabjavacript close current tabbutton close browser java scriptjs close chrome tab from idtypescrip clode current tabclose bcurrent browser tabjs close tab on click outsidejavascript document close in new tabclose tab javascript without promptjavascript to close window in chromehow to close a tab with javascriptjs before tab closejavascript close tab windowdom on tab will closeclose current tab in javascriptjs on tab close openclose current tab and open new tab in javascriptclose current window using opnjs code to close current tabjavascript function to close new open tabshow to programmatically close current tab in javascriptbrowser tab close event in javascript examplestop anyone closing the tab javascriptjs close other tabsjavascript close url tabclose current tab javascript w3schoolsclose a tab using jsjs on close tab eventevent close tab browser javascriptwindow close javascripton close tab javascriptbrowser tab exit on clickhow to autoclose a tab using jsclose current tab chrome jsclose the tab in javascript using 3ca 3eclose current tab htmlcheck close tab javascripthow to close a site in jshow to close the page in javascriptclose current tab with javascriptevent close tab javascriptjavascript how to close current windowclosing a tab on the click of aa button jsbrowser event on tab closeclose tab javascript 5ctab switching event javascriptopen close tab htmlphp make button to close current tabhow to close window tab in another window javascriptjs close tab eventonclick 3d 22windowclose 28 29 3b 22 new tabjavascript close tab programmaticallyhtml button to close current tabjavascript close chrome tabclose firefox tab from javascriptjs close new tabclick to close tab in javascript codewindow tab close event javascripthow to close a code with jsdom windom close tabjavascript how to close tab in iosdetect close tab javascripthow to make it so that someone cant close the tab in jsclose specific tab javascriptonclick 3d 27window close 28 29 preciso do javascript 3fclose browser javascriptfirefox close tab using jsevent on close tabcmd close page if is on urlclose current tab jscurrent tab close javascriptjs close tab on button clickclick button and close browser current tab javascriptjs close pageprevent tab from closing javascripthow to close the browser tab using javascriptjavascript call function on tab closeclose a tab from jscan i close tabs in javascriptclose tab via javascrptjs window closejavascript event close tabclose tab browser javascriptjavascript closetabclose the ie tab javascriptclose tab from htmlon tab close javascriptclose tab in jsclose a tab using javascriptjquery onclick close pagejavascript button click close tabclose tab using javascripthow to click a close current tabprevent browser close tab javascripton browser tab close jsthis close javascripthow to quit a tab in javascriptclose one tab only in javascriptcurrent browser tab in javsacriptclose tab jshow to close a google tabe with javascriptjavascript how to close different browser windowhow to close current tab in jsjavascript to close tabjavascript detect tab closejavascript close tabclose chrome tab using javascriptjscript close openned tabscerrar tab javascriptclose tab eventclose existing tab on browser using javascripthow to close current tab in chrome using javascripthow to close tab using jshow to close tab javascriptexit page opened in same windowjavascript close pagejavascript code to close current tabclose tab in browserjs close tab from another scriptdetect only browser tab close event in javascriptdetect the browser tab close event in javascriptclose open tab javascriptcan 27t close current tab jquerywhen user clicks exit the website should close the current tabvhow to close tab with jsclose current ta javascriptjavascript how close the last browser tab openlet user click a button to close current browser tabjavascript function to close tabjs code to close a tab when clickedjs close current tab 2f 2fcloses the current browser tabjs window close tabclose the tab using javascripthow to close a window htmltab closing in javascriptchrome close tab event javascriptjs on close tabforce closing of current window browserclose new tab javascriptjs how to run function when close tabon tab close eventclose current tab meta in htmlhow to close particular tab in browser javascriptjs tab on closehow to close launched tab with jsjs window on closing the whole browser and not only tabjavascript before close tabnodejs how to close a another tab in browserjs close another tabscript to close browser tabclose tab javascript chromeclose active tab with jsrecognize close tab javascriptclose tab instead of whole browser in javascriptclose another tab javascriptclose the current window tab on a web browsers in javascripthow to close another tab using javascriptjavascript open tab and auto close ithow to close tab on button click in javascripthow to handle tab close event in javascripton browser tab close javascriptjavascript tab closeie close the tab when access pageeon browser tab close eventhow to make a button that closes the current tab close chrome tab with javascripthow to close a page in javascriptclose tabs wwith jsclose tab dialogue javascriptjavascirpt close the tabjavascript window close tab and set activejavascript close tab chromejavascript tab close eventclose current windowconsole close current tab chromeon tab close event javascripttab close javascript eventjavascript how to close a tabjs close opened tabclose tab html javascriptjs open new tab per clickeclose current window jshow to get reference of an current tab and close it in javascriptjavascript close this tabclose the tab javascriptclose this tab jshow to close current tab in a browser window using javascripthow to close all tab if already open in javascriptjavascript browser tab before close eventjavascript to close browser developer tabhtml closw tabfunction to close current tab jshow to close own tab java scriptecent closed tab in jsjs stop browser from closing tabjs fuction to close the tabclose tab onclick javascriptjs check if tab is reloading or closingjavascript browser close tabjs close tab event listnerclose a tab from jjs close opened by linkjs on click close tabwindow close current tabevent on close browser tab tab javascriptclose current tab in jsjavascript close previous tabjavascript prevent tab closehtml tab schlie c3 9fenhow to close tab with javascriptjavascript close a tabjavascript close current tabclosing a tab with jsjavascript on tab closehow to close a chrome tab from within the javascriptjs close current tab chromeuse javascript to close a window or tabjs detect tab closejavascript to close browserclose browser tab on javascript buttonclose the browser in javascript close tab javascriptclose browser tab using javascriptjs close tab rightclose the tab in javascriptevent whenb user close tab window browser js close tab with javascriptclose current tab javascript extensionchrome tab on close jsclose tab function javascriptbutton to close tabhtml quit in responce to javascriptautomatically close new tabl javascriptjs close tab itselfhow to close current tab in a browser windowclose all tab javascriptres close current windowhow to keep current tab javascriptbrowser window close latave 3b how close a chrome tab javascriptcannot close tab in jshow to close browser tab using javascripttab close event javascriptwindow close tabclose page opened inside pagejs close current tabjavascript close current tabjavascript window close tab go toclose chrome tab typescriptjavascript close tab buttonclose a open tab in jsclose open tab javascript eventhtml close current webpage buttonclose current tab using jsclose tab from code jsclose tab on button clickjavascrit close tabwhen you close the tab or window in javascriptauto close tab javascriptjs close a windowjs to close tabhow to close the tab in jsclose a tab jshow to close control the browser tabs using javascripthow to know when a tab get close javascripthow to close the current tab jshow to close a tab jsclose browser tab in javascriptclose chrome tab on click javascripthow to close the box current tab in javascriptjs browser other tab closeclose tab by name in javascriptscript to exit browser tabjs close out of tabclose tab with jsjavascript close tab on button clickclose another tab with javascripttab close using javascriptevent close current tab javascriptclose current tab javasciptclose window javascriptjs tab close eventclose tab 2b javascriptjavascript to close current tabjs do a request the close tabjavascript when i click on a tab the other one closesjs script that closes siterun function on tab close javascriptchrome tab close javascriptwhy wont my tab close with close 28 29 3b javascripthow to close already opened all tab in javascriptwindow last tab in javascripthow to make a window open from where it was closed in javascriptclose opened tab javascriptclose the browser javascripthow to close current tab in javascriptclose newly created tab with javascriptjavascript close popped up tab from master tabhow to close href tabscript close tabclose current tab in htmlclose browser tabs and go to left tab javascriptjavascript close windowwindow close tabhow to close the current tab in javascriptclose tab in js without user onclickhow to close tab jshow to make your webpage close automaticallytab close event in javascriptclose tab onclick javascript eventjs close tab and open new tabclose other tabs jsopen tab closed pure htmlhow to close your website tab using javascriptclose window all tab javascriptclose page jsclose tab that is on in js and open in new tabhtml javascript close tabhow to force a tab to close with javascriptclose the browser tab in javascriptclose current tab in browser javascriptjs close tab after click of buttonjs close this window 2ftabjavascript close when tab offjavascript code to close tab eventclose a tab javascripthow to close a window tab in javascriptcurrent tab closing in javascripthow to close particular tab in a browser window js 3fhow to close current tab of browser using javascriptjs fuction to close a tabhref close windowclose current tab and open new tab jsjavascript browser tab close eventhow can i detect that tab is close in javascriptjs tab closejs link to close current tablet user click a button to close current browser tab in chromeonclick close current window javascriptwindow location close tabhref to close windowjavascript close tab and get elements to put into a different tabclose browser tab from htmlwindow event tab closeclose tab javascript eventforce close a browser tab jsonclick javascript new page close currentclose browser tab with javascripthow to close tab in chrome using javascriptaction when tab close jsjs detect close browser 2c tabhow to close current tab in chrome javascriptclose tab in htmlhow to close current tab and open new tab in javascriptjs close tab openedhow to close a tab in javascriptgoogle js close tabjs function to ope n tab and close it javascript print and close tabhow to close tab by javascripthow to close current tab in javascritclose self tab javascripthref javascript 3aclosewindow 28 29how to close a tab in browser javascripthref javascript onclick window closeclose tab by url javascriptjs close other tabs on loadclose user tab javascriptjavascript close current browser tabjavascript 3aclosecurrentwindow mobilelink opens in same window how to close the browser window through buttonclose current tab jshow to close the tab in javascriptclose acordion tab by jsclose current tab a hrefclose other tabs chrome javascripthow to close chrome tab in javascriptclose browser tab on button click in javascriptjs close chrome tabjs close tab after downloadhow do you close a tab with a html codejavascript detect close tabjavascript close tab or windownode js close tab mozillastop the function if i move to another tab javascriptonclick close internet exploreropen a new tab and exit current by javaclose another tab from jshow to force close tab in javacriptjs how to close current tabclose tab button javascripthow to close a tab using jshow to close current web page in javascripthow to force closing tab javascripthow can a tab close itself jscall javascript function on tab closehtml script close tabjs close a tab opend by scriptjs close tapjavascrt close tabhref close pagehow to close a browser tab using javascripthow to close a tab javascriptdetect tab close javascriptclose a tab htmlclose window programmatically javascriptbtn close actual onglet when close tab or window jshow to close new opened tab in a browser js 3fhow to detect tab close from another tab in jsprevent closing tab javascripthtml close tabjavascript script to close before one tabclose window in javascriptjavascript close tab blankjavascript script to close current tabclose a tab with javascriptclose browser tab which is not opened through js scripthtml close tab event jshow to close the browser tab with javascripthow to close the browser tab on click 2b javascripthow to close a browser window or tab with javascripthow to close current browser window in javascriptjavascript close differtnt tablink to close windowchrome tab close event in javascriptclose tab using javscrit 27close current tab in chrome javascripthow to perform some event if the browser tab close in jshow to prevent tab close in javascripthow to close browder tab using http codehow to close the current tab with javascripthow to close a tab when we click on x button in javascriptopen and close tab javascriptopen close tab button javascriptjavscript close all tabsclose current tab on button clickevent on close tab javascriptbutton close tab jshow to close a tab via javascriptopening and closing tab htmlset new tab close without javascripthref that closes tabalert when closing tab jsclose a opened tab in javascripthow to close tab in jshow to detect tab close in javascriptclose current tab on print javascripthow to close the current tab in chrome using javascripthow to close browser in javascriptclose tab button htmlhtml close current tab or windowclose tab browser javascritpwindow close different tab javascriptclose the current tab in javascriptclose tab htmlclose and open tab in jswindow open close current tabcross browser close tab javascriptclose current tab linkhow to detect a close tab or reload in javascriptnode js close browser tabclose current tab javascript eventopen a page when closing the tabjava script command to close taphow to close all tab in javascriptjs event on tab closehow to close tab by javasriptprevent close tab javascriptjs ios dont close tabjavascript close tbajs close browserhtml5 close browser tab using javascriptclose tab via javascriptclose tab javascriptclose the current tab javascriptclose tab event javascriptclose tab which are not open with js js open and close tabclose current window javascriptjs function to close the tabhow to close a tab with jsclose tab in javascriptclose the window tabjs close current browser tabclose tab in js without onclickjavascript close specific tabjs close tab onclickhow to detect tab close in jsjs close tab opened by linkclose current tab jquery androidjavascript after closing the tab go back to the other tab that openedclose the tab through jshow to close tab in javascriptclosing tab javascriptclose current tab on button click javascriptchrome js close tabjava script close tabjavascript close browser tabclose a tab in json tab close event jsclose card javascriptturn off javascript for a tabclick close tab javascriptclose current window in angularleave tab jstab close run function in jsjs action on tab closejs how to run function when the tab is about to closeclose window page javascripthow to close browser tab in javascriptjs close tab opened by acreating closeable tabs javascripttab close js eventclose current tab using javascriptclose tab by click javascriptwindow closehow to close a tab in jshow to close a tab opened in javascript htmlonclick open and close tab htmljs close browser tabjavascript close tab browserclose a tab in chrome using javascripthow to close tabs using javascriptforced close window tabs by using javascriptclose all other tabs on a window javascriptjavascript event close browser tabjavasdcript close tabhow to close current tab javascriptcan you close browser tab using javascriptclose tab from javascriptclose window tab jshow to opne and close a tab in jsjavascript close new tabhow to exit a web application from browser in jqueryclose current tab java scriptget tab close event javascriptturn off a tab in browser javascriptjs before close tabclose current tab javascripthow to do tab close in jstab close javascriptclose google page javascriptprevent closing tab jsclose browser tab jsclose window tab javascriptjavascript when close tabjscript close current tabscript to exit browser tab without opening js detect close tabjavascript how close the last browser tabclose tab chrome javascripthow to close a tab in javascript that was open new tabhow to close the existing tab using javascripthow t close tab after it opens javascriptjavascript window tab close alerthow to open a link and close previus tab javascript html 5how to close current tab by javascripttab close js functiondo code when close tabstop close tab with javascriptclose browser tab with jscall event on close tab browser javascripthow to close the tab jshow to close tab using javascriptjs close tabprevent tab close javascriptclose page script htmljs close active tabjs on tab closejavascript open new tab and close currentclose current tab onclickclose current browser tab javascripthow to close tab by javascript