PY_*_*PY_ 2 google-apps-script
有没有办法在Google Apps电子表格的消息框中添加超链接?
我有这个显示msgbox的代码.
// The code below will display a message box
Browser.msgBox("Go to this site for help");
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在该消息框中插入超链接?就像是:
// The code below will display a message box
Browser.msgBox("Go to this site for help" & <a href="www.google.com">Help</a>);
}
Run Code Online (Sandbox Code Playgroud)
截至2014年12月11日,Google的UI服务已被弃用.请参阅此处.
您现在应该使用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');
Run Code Online (Sandbox Code Playgroud)
Google Sheets似乎不会为打开公共电子表格的任何人运行脚本(显然是出于安全考虑).如果要查看对话框的实时版本,只需将上述代码复制到function onOpen() {}脚本编辑器中,保存并刷新电子表格即可.否则,它看起来像下面的图像.
如果HTML比简单链接多,则还可以从HTML文件创建对话框.在脚本编辑器中,选择" 文件" >" 新建" >" Html文件"并将其命名为"index"(或任何您想要的名称并在代码中更改文件名).
var html = HtmlService.createHtmlOutputFromFile('index');
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showModalDialog(html, 'Dialog title');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8823 次 |
| 最近记录: |