Google电子表格应用脚本:HTML服务中的对话框在嵌入时未加载

时间:2018-04-26 21:02:52

标签: google-apps-script google-sheets embed

我遇到了一个问题,我创建了一个自定义对话框,使用HTML服务显示一些非常基本的HTML输出。这在Google表格中效果很好,但是当我将可编辑的Google工作表嵌入到其他网站时,内容将无法加载。

使用检查器/控制台,我了解到该问题可能与"拒绝在框架中显示{link}有关,因为它设置了“X-Frame-Options' to' sameorigin'。"我引用https://developers.google.com/apps-script/guides/html/restrictions并认为我已遵循所有相关说明,但我已无法在几周内解决此问题

我不是开发人员,只是涉猎,所以即使只是了解如何处理这个问题的资源也非常受欢迎。

以下是我的代码。谢谢你的时间!

HTML:

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
    Hello, world! <input type="button" value="Close" onclick="google.script.host.close()" />
  </body>
</html>

GS:

function showDialog() {
   var html = HtmlService.createHtmlOutputFromFile('showDialogPage')
   .setWidth(400)
   .setHeight(300)
   .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);


SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
    .showModalDialog(html, 'My custom dialog');
}

0 个答案:

没有答案