我正在使用基于 html 模板的 Google 应用程序脚本开发独立的网络应用程序。该应用程序的目的是一种简单的 gmail,但带有自定义过滤器。我已经完成了该过滤器并显示了电子邮件列表,但在呈现消息的 html 正文时遇到了问题。
部分代码如下:
HTML 模板:
<table id="myTable">
</table>
<script>
...
for (var i = 0; i < threads.length; i++)
{
var row = table.insertRow(0);
row.setAttribute("messageId", threads[i].id);
row.onclick = (function() {
google.script.run.openMessage(this.getAttribute("messageId"));
});
var cell1 = row.insertCell(0);
cell1.innerHTML = threads[i].subject;
}
...
</script>
谷歌脚本:
function doGet() {
return HtmlService
.createTemplateFromFile('index')
.evaluate().setSandboxMode(HtmlService.SandboxMode.NATIVE);
}
...
function openMessage(id)
{
var message = GmailApp.getMessageById(id);
var body = HtmlService.createHtmlOutput(message.getBody());
}
...
问题是:点击时显示邮件正文的最佳方式是什么?当我尝试在新窗口中打开它时 (window.open()...
)b 出现错误,模态窗口也无法在 html 模板中工作。
在此先感谢您的帮助!
最佳答案
我终于找到了我的问题的答案,它是——jquery对话框。
<div id="dialog"></div>
function openDialog(html) {
$("#dialog-confirm").html(html);
$("#dialog-confirm").dialog({
resizable: true,
modal: true,
title: "Message",
height: 500,
width: 500,
});
}
关于javascript - 从 Google 应用程序脚本 html 模板呈现 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27003467/