我通过谷歌应用脚本中的 Html Services api 创建了一个网页。在脚本中,我有一个 google 脚本(.gs)文件和两个 html 文件(.html)。该脚本发布在网络上。为了在 web 上显示 html 文件,我在 .gs 文件中使用了以下函数:
function doGet() { //Published on web
return HtmlService.createTemplateFromFile('<htmlFile_1>').evaluate();
}
function doProcess() {
return HtmlService.createTemplateFromFile('<htmlFile_2>').evaluate();
}
doGet() 在网络上返回这个 Html 文件。现在我想通过替换这个文件来显示另一个 Html 文件。所以,我在 htmlFile_1 中使用了以下内容:
//htmlFile_1.html
<html>
<head>
<script>
function loadMainHtmlPage(){
google.script.run.doProcess(); //calling another function in .gs file
setTimeout(function(){hello()},4000);
}
function hello(){
alert("hiii");
document.getElementById("loading").style.display="none";}
</script>
</head>
<body onload="loadMainHtmlPage();">
<div id="loading" style="display:block;">
<img src="http://commondatastorage.googleapis.com/kickoff/loading.gif"/>
</div>
</body>
</html>
这个 htmlFile_1 没有调用 doProcess(),它会返回 htmlFile_2。有什么建议可以实施吗?