HtmlService中的href [英] href in HtmlService
问题描述
我在我的google apps脚本项目(showHtml1,showHtml2)中有2个html文档。
我服务第一个
$ p $函数doGet(){
')。评估();
}
和第一个html里面我想包含href到第二个html showHtml2)。
是否有可能?
此示例应该会显示您的模式。您可以在任何使用HtmlOutput对象的地方使用Html文件。
$ b
函数doGet(requestInfo){
var url = ScriptApp.getService() .getUrl();
if(requestInfo.parameter&& requestInfo.parameter ['page'] =='2'){
return HtmlService.createHtmlOutput(
This is Page 2.< a href ='+ url +?page = 1'>页面1< / a>);
}
return HtmlService.createHtmlOutput(
This is Page 1.< a href ='+ url +?page = 2'> Page 2< / a>) ;
请记住,在处理ScriptApp的URL时, url,而不是dev模式的url,所以如果你正在尝试你可能想用/ dev替换/ exec。
I have 2 html documents inside my google apps script project (showHtml1, showHtml2). I serve the first one by
function doGet() {
return HtmlService.createTemplateFromFile('showHtml1').evaluate();
}
and inside the first html i want to include the href to the second html (showHtml2). Is that possible?
This sample should show you the pattern. You can use Html files wherever I used HtmlOuput objects. I just wanted to keep it simple.
function doGet(requestInfo) {
var url = ScriptApp.getService().getUrl();
if (requestInfo.parameter && requestInfo.parameter['page'] == '2') {
return HtmlService.createHtmlOutput(
"This is Page 2. <a href='" + url + "?page=1'>Page 1</a>");
}
return HtmlService.createHtmlOutput(
"This is Page 1. <a href='" + url + "?page=2'>Page 2</a>");
}
Bear in mind when working with this that the URL from ScriptApp will be the deployed url, not the dev mode url, so if you are experimenting you might want to replace the "/exec" at the end with "/dev".
这篇关于HtmlService中的href的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!