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

How to open a new page from a button in a Dialog Box?

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

此框是使用以下方法创建的:

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,而我需要它们。

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

您需要使用 IFRAME 模式:

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

下面是我的第一个回答:

对话框中的 <a> 标签将在新标签页中打开 link。

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

这不是按钮,但您可以使用 link,并将其样式设置为看起来像按钮。

<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>