如果您使用自定義對話框而不是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對話框並讓用戶點擊一個錨點。向我們展示你的嘗試。 –