如果您使用自定义对话框而不是alert
,则可以执行此操作。自定义对话框通过允许您定义自己的html更加强大。只需在附加到工作表的脚本中创建以下文件。
Code.gs
function onOpen() {
openWelcomeDialog();
}
function openWelcomeDialog() {
// get the html from the file called "Pages.html"
var html = HtmlService.createHtmlOutputFromFile('Pages');
// open the dialog
SpreadsheetApp.getUi()
.showModelessDialog(html, "Welcome to HAVENLY Offshore Team Workspace!")
}
Pages.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body>
<!-- target="_blank" directs the link to a new blank tab -->
<a target="_blank" href="http://stackoverflow.com/questions/17711146/how-to-open-link-in-new-tab-on-html">
Check out our CONFLUENCE updates today!
</a>
</body>
</html>
更新 你也可以关闭该对话框时,与该链接用户点击onclick
事件处理程序:
<a onclick="google.script.host.close()" target="_blank" href="||url||">
Check out our CONFLUENCE updates today!
</a>
不可能这样。建立一个小的webapp对话框并让用户点击一个锚点。向我们展示你的尝试。 –