[英]How I make a pop up box in Google Script
如何使用“是”或“否”选项创建一个对话框,以便如果该人单击“是”,它将在 Google 脚本中运行 function。
使用Browser.msgBox()
并传递所需的ButtonSet 。
function getConfirmation() {
var response = Browser.msgBox("Are you sure?", Browser.Buttons.YES_NO);
if (response === "yes") {
// do something
}
}
我更喜欢在创建弹出框时使用Class Ui ,因为您可以使用它们做更多事情:
对于简单的是否框,请使用警告框
function alertBox() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sh = ss.getActiveSheet();
var ui = SpreadsheetApp.getUi();
//create the message box, style is ("Title","Message", Buttons)
var response = ui.alert("Response", "Yes to run, no to stop", ui.ButtonSet.YES_NO) //Buttons: YES_NO, OK, OK_CANCEL, YES_NO_CANCEL
if (response = ui.Button.YES){
//enter your script here
}
}
相信这可以帮助您解决问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.