有没有一种方法来添加一个谷歌Apps的电子表格的消息盒子里面的超链接?
我有这样的代码,显示一个MsgBox。
// The code below will display a message box
Browser.msgBox("Go to this site for help");
}
是否有插入在消息框中的超链接,以及一种方式? 就像是:
// The code below will display a message box
Browser.msgBox("Go to this site for help" & <a href="www.google.com">Help</a>);
}
这是示出一个链接到URL的弹出的一个例子
function showurl() {
var app = UiApp.createApplication().setHeight('60').setWidth('150');
app.setTitle("Anchor in a popup ;-)");
var panel = app.createPopupPanel()
var link = app.createAnchor('This is your link', 'https://sites.google.com/site/appsscriptexperiments/home');
panel.add(link);
app.add(panel);
var doc = SpreadsheetApp.getActive();
doc.show(app);
}
谷歌的用户界面服务已废弃12月11日,2014年的见这里 。
现在,您应该使用HTML服务 。 用链路是下面的代码来显示消息。
var htmlOutput = HtmlService
.createHtmlOutput('Go to <a href="https://www.google.ca/">this site</a> for help!')
.setWidth(250) //optional
.setHeight(50); //optional
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Help Dialog Title');
看来谷歌的工作表不会运行谁打开了一个电子表格公开任何人(显然是出于安全考虑)的脚本。 如果你想看到的对话框的真人版,只是上面的代码复制到function onOpen() {}
在脚本编辑器,保存和更新电子表格。 否则,它看起来像下面的图片。
如果您有一个简单的链接更多的HTML,你也可以创建从HTML文件的对话框。 在脚本编辑器,选择File> New> HTML文件并将其命名为“指数”(或任何你想在代码更改文件名)。
var html = HtmlService.createHtmlOutputFromFile('index');
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showModalDialog(html, 'Dialog title');