I have a web app in Google Apps Script and I need that when I have click in a Button, the browser tab closes. I tried with different solutions but it does not work as I require it.
This is my HTML code.
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<h1>Demo Close tab</h1>
<p>When you click the button, you must close this tab.</p>
<button>Close</button>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script>
window.onload = function() {
$("button").click(function() {
// window.close();
// window.top.close();
// window.open("","_top","").close();
});
}
</script>
</body>
</html>
And this is my GS code
function doGet() {
var template = HtmlService.createTemplateFromFile("Index");
return template.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.addMetaTag("viewport", "width=device-width, initial-scale=1")
.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL)
.setTitle("Demo Google Analytics");
}