0

我正在尝试使用 Apps Script 方法在 Google Apps ScriptsetContent()中添加一个简单index.html文件的链接。

  var newDocLink = "https://docs.google.com/document/d/1loBt7T7-4qd0ORBXiTFeDQxuG..."; 
  // newDocLink variable have some Google Docs URL as value
  var output = HtmlService.createHtmlOutput('Click <a href= " '  + newDocLink + ' ">here to open the link in a new tab</a> a minuta')
  SpreadsheetApp.getUi().showModalDialog(output, 'My page title');

我得到了链接,但是当我单击它时,它不起作用,以我的语言显示此消息“与 accounts.google.com 的连接已被撤回”。

我知道这很简单,但我对 HTML 知之甚少,在寻找类似问题后,没有找到解决方案或类似用途的代码。任何帮助将不胜感激!

4

1 回答 1

1

问题:

  • 您正在尝试在 iframe 中打开 Google 文档,而 Google 文档不允许这样做。

解决方案:

  • target通过设置属性在新选项卡中打开它

    var output = HtmlService.createHtmlOutput('Click <a rel="noreferrer noopener" href= " '  + newDocLink + ' " target="_blank">here to open the link in a new tab</a>')
    

参考:

于 2019-01-30T17:28:02.377 回答