I am using the HTMLService to create a standalone google apps script web app. I want to be able to write code to take clicks on links on the HTML page for the app and go to the pages that are in the links. Much like a regular web page, except as a Google Web App. The normal ">Click me doesn't work.
Here is what I am doing:
Code.gs
/*
* Main function, sets up webapp ui.
*/
function doGet() {
return HtmlService.createHtmlOutputFromFile('Index')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
}
function navigateTo(url) {
return HtmlService.createHtmlOutputFromFile(url)
.setSandboxMode(HtmlSerivce.SandboxMode.IFRAME);
}
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function handleNavigation() {
//Logger.log("Hello from handleNavigation, within Index.html");
google.script.run.navigateTo('EditUsers')
document.getElementById("test").innerHTML = "Success!";
}
</script>
</head>
<body>
<h1>Home</h1>
This is the beginning of the Project Status Web App<br/>
<a href="EditUsers.html">Edit Users</a><br/><button
onclick="handleNavigation()">Button Time!</button>
<a id="test" href="EditProjects.html">Edit Projects</a><br/>
<a href="ViewProjectStatuses.html">View Project Statuses</a><br/>
</body>
</html>