google-apps-script - 如何通过代码打开多个网址,我们有一个代码,但它只有一个网址
问题描述
我们有以下脚本,我们在谷歌脚本编辑器中运行它,它工作正常,但它只打开一个 url,如果我们想打开多个 url,我们该怎么做
功能是
function myFunction() {
var js = " \
<script> \
window.open('https://stackoverflow.com/', '_blank', 'width=800, height=600'); \
google.script.host.close(); \
</script> \
";
var html = HtmlService.createHtmlOutput(js)
.setHeight(10)
.setWidth(100);
SpreadsheetApp.getUi().showModalDialog(html, 'Now loading.');
}
解决方案
有了window.open
您可以打开任意数量的窗口
在两个不同的窗口中打开两个 url 的示例:
function myFunction() {
var js = " \
<script> \
window.open('https://stackoverflow.com/', '_blank', 'width=800, height=600'); \
window.open('https://www.wikipedia.org/', '_blank', 'width=800, height=600'); \
google.script.host.close(); \
</script> \
";
var html = HtmlService.createHtmlOutput(js)
.setHeight(10)
.setWidth(100);
SpreadsheetApp.getUi().showModalDialog(html, 'Now loading.');
}
推荐阅读
- c# - 在 WPF MVVM 中使用不同的 UI 元素绑定画布
- qgis - 为什么 georeferencer 对我的输入图像执行此操作?
- spring-boot - 如何在 spring-boot 中使用 ElasticsearchRestClientAutoConfiguration?
- mysql - phpMyAdmin:如何将 BINARY 或 VARBINARY 编辑为文本?
- ruby - 有没有办法在 golang html/template 中删除前点评估
- javascript - 如何在 MongoDB 中同时使用匹配和求和?
- java - 我可以更改通知渠道的重要性吗?
- javascript - 防止运算符在计算器中连续显示多次
- r - 关于聚集标准错误
- ios - 如何在 Xcode 或 Swift 中为 iOS 应用程序设置初始语言?