I am trying to run a script that when a if()
statement returns false
it closes the current tab window of the google sheet or it redirects to another URL (as long as one of these work, thats ok for me).
I understand that this may be possible through using HTML but i don't know HTML well enough to do this.
I have found the below code which is meant to redirect to a different page which I tried but this does not work:
return HtmlService.createHtmlOutput(
"<form action='http://www.google.com' method='get' id='foo'></form>" +
"<script>document.getElementById('foo').submit();</script>");
Does anyone have any ideas?
See code that this is in below below:
if (name == password)
{
Browser.msgBox('You have succesfully logged in');
sortOutSheets();
}
else (name != password)
{
var response = Browser.msgBox('Login Failed - do you want to login again?', Browser.Buttons.YES_NO);
if(response == "yes")
enterPassword();
else(response == "no")
HtmlService.createHtmlOutputFromFile('Close Window');
}
}
I have now turned to writing the HTML in another HTML file but still no luck