Close Tab | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Close Tab

How do you close a tab in html or js? This will work han-in-hand with a confim box.

5th Dec 2016, 2:44 AM
Möbius
Möbius - avatar
1 Answer
+ 2
You have to check what the user has pressed: if(confirm("Close Window?")){//a confirm box is shown { //user pressed yes window.close(); //closes the current tab } else { //user pressed no //do something else }
5th Dec 2016, 10:37 PM
Patrick G.
Patrick G. - avatar