如何从对话框中的按钮打开新页面?

时间:2015-02-25 19:52:37

标签: google-apps-script

如何从对话框中的按钮打开新页面?

此框使用:

创建
var html = HtmlService.createTemplateFromFile('File')

这是File.html

function sabermais(){
  window.open('www.google.com')
}

<input type="button" class="action" value="Learn more" onclick="sabermais()" />

如果使用以下方式调用该框,则可以正常工作:

var html = HtmlService.createHtmlOutputFromFile('File')

但在这种情况下,我无法使用scriplets,我需要它们。

这听起来有点令人困惑,但我想有人可以提供帮助。 提前谢谢!

1 个答案:

答案 0 :(得分:0)

您需要使用IFRAME模式:

var html = HtmlService.createTemplateFromFile('File')
  .evaluate()
  .setWidth(450)
  .setHeight(450)
  .setSandboxMode(HtmlService.SandboxMode.IFRAME);

我的第一个答案如下:

对话框中的<a>标记会在新标签中打开一个链接。

<a href="https://www.google.com">button</a>

这不是一个按钮,但您可以使用链接,并将其设置为看起来像一个按钮。

<a style="border: 1px solid #990000;
  background-color: #CCCCFF;
  margin-left: 10px;
  padding: 0 1em;
  height: 2em;
  width: 30px;
  cursor: pointer;
  text-align: center;
  " href="https://www.google.com">button</a>