在Google脚本中打开另一个模态对话框中的模态对话框,可以通过以下步骤实现:
google.script.run
方法调用一个服务器端函数,该函数用于打开第二个模态对话框。SpreadsheetApp.getUi().showModalDialog
方法打开第二个模态对话框。下面是一个示例代码:
// 第一个模态对话框的Google脚本代码
function openFirstModalDialog() {
var htmlOutput = HtmlService.createHtmlOutput('<button onclick="openSecondModalDialog()">打开第二个模态对话框</button>');
SpreadsheetApp.getUi().showModalDialog(htmlOutput, '第一个模态对话框');
}
// 第二个模态对话框的Google脚本代码
function openSecondModalDialog() {
google.script.run.openSecondModalDialog();
}
// 服务器端函数
function openSecondModalDialog() {
var htmlOutput = HtmlService.createHtmlOutput('第二个模态对话框');
SpreadsheetApp.getUi().showModalDialog(htmlOutput, '第二个模态对话框');
}
在上述代码中,openFirstModalDialog
函数用于打开第一个模态对话框,其中包含一个按钮,点击按钮会调用openSecondModalDialog
函数。openSecondModalDialog
函数通过google.script.run
方法调用服务器端的openSecondModalDialog
函数。服务器端的openSecondModalDialog
函数会创建第二个模态对话框并打开。
请注意,这只是一个简单的示例,实际应用中可能需要根据具体需求进行修改和扩展。
领取专属 10元无门槛券
手把手带您无忧上云