【问题标题】:Yes/no user prompt to continue or stop the script是/否用户提示继续或停止脚本
【发布时间】:2017-08-25 10:16:52
【问题描述】:

我有一个很好的谷歌应用程序脚本,它工作正常,但它会导致删除我的谷歌电子表格中的工作表,因此我希望脚本以是/否提示开始,询问“你确定要关闭工作”。如果他说是,很好,继续,如果不是,退出脚本。

有什么想法吗?提前致谢!

【问题讨论】:

    标签: google-apps


    【解决方案1】:

    找到这个

     // Display a dialog box with a message and "Yes" and "No" buttons. The user 
    can also close the
     // dialog by clicking the close button in its title bar.
     var ui = SpreadsheetApp.getUi();
     var response = ui.alert('Are you sure you want to continue?', 
    ui.ButtonSet.YES_NO);
    
     // Process the user's response.
     if (response == ui.Button.YES) {
       Logger.log('The user clicked "Yes."');
     } else {
       Logger.log('The user clicked "No" or the close button in the dialog\'s 
    title bar.');
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-08
      • 1970-01-01
      • 2022-01-19
      • 2018-08-22
      相关资源
      最近更新 更多