how to close tab by javascript code example
Example 1: how to close tab by javascript
<button onclick="window.close();">Exit</button>
function closeWin() {
myWindow.close();
}
function openWin() {
myWindow = window.open("", "myWindow", "width=200, height=100");
}
Example 2: close browser tab javascript
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
window.open("/folderDirectory/example.php");
</script>
</head>
</html>
$(document).ready(function(){
$("button").click(function(){
window.close();
});
});
<button style="border: none;" >Exit</button>
Example 3: how-to-close-current-tab-in-a-browser-window
Writing 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.