这是交易,
我在Googl应用程序脚本IDE上工作 有四个HTML文件,我想将它们合并到一个HtmlOutput对象中。
Template.html
Content.html
Script.html
Style.html
以下是我想要的内容:
将Script.html和Style.html放入我的Template.html部分 并将Content.html放在我的身体部位。
问题是我无法找到将HtmlOutput对象输出转换为Document Object的方法,这样我可以使用InnerHtml proprerty。
提前致谢,
答案 0 :(得分:0)
使用HtmlSerivce模板。 看一下Htmlservice模板的最佳实践。它显示了如何做到这一点。
基本思想是,您的文件包含模板标记,该模板标记是从项目中的其他html文件构建的。
page.html中
<?!= include('Stylesheet'); ?>
<h1>Welcome</h1>
<p><?!= include('Content'); ?></p>
<?!= include('JavaScript'); ?>
code.gs
function doGet(request) {
return HtmlService.createTemplateFromFile('Page')
.evaluate();
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.getContent();
}