I want to create a link on a webpage that would close the currently active tab in a browser without closing other tabs in the browser.
When the user clicks the close link, an alert message should appear asking the user to confirm with two buttons, "YES" and "NO". If the user clicks "YES", close that page and If "NO", do nothing.
How can it be done? Any suggestions?
This method works in Chrome and IE:
Try this as well. Working for me on all three major browsers.
Here's how you would create such a link:
<a href="javascript:if(confirm('Close window?'))window.close()">close</a>
As far as I can tell, it no longer is possible in Chrome or FireFox. It may still be possible in IE (at least pre-Edge).
Try this