[英]How to use google script web app with multiple pages in google site?
Here's the thing: I have a web app that has multiple html pages in it.事情是这样的:我有一个 web 应用程序,其中有多个 html 页面。 Code is embedded in a Google spreadsheet.代码嵌入在 Google 电子表格中。 During development I call each page by a separate doGet() function;在开发过程中,我通过单独的 doGet() function 调用每个页面; commenting out the ones I don't want to use.注释掉我不想使用的那些。 I managed to put my google sheet into the site, end embedded the Web App code for one page.我设法将我的谷歌表格放入网站,最后嵌入了一页的 Web 应用程序代码。 I want to put each of my html pages in different site pages.我想将我的每个 html 页面放在不同的站点页面中。 So how do I call each html page, from the the different doGet functions?那么如何从不同的 doGet 函数调用每个 html 页面? Thanks.谢谢。
You can pass the page name through query string:您可以通过查询字符串传递页面名称:
function doGet(e) {
var t = HtmlService.createTemplateFromFile(e.parameter.page);
return t.evaluate();
}
For example, you have Home.html
and About.html
, you can show these pages by using:例如,您有Home.html
和About.html
,您可以使用以下方法显示这些页面:
https://script.google.com/macros/s/.../exec?page=Home
https://script.google.com/macros/s/.../exec?page=About
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.