Simple popup or dialog box in Google Apps Script

前端 未结 4 1919
情深已故
情深已故 2021-01-12 18:29

I\'m looking for simple code that adds a popup in my Google Apps Script Ui that comes up when I hit a submit button. The popup box would display a message and have a button

4条回答
  •  时光取名叫无心
    2021-01-12 19:05

    Since UiApp is depreciated, HTMLService should be used to create custom user interfaces.

    To prompt simple popup to display a message, use alert method of Ui class

    var ui = DocumentApp.getUi();
    ui.alert('Hello world');
    

    will prompt simple popup with hello world and an ok button.

    To display customized html template in Dialog, use HTMLService to create template and then pass it to showModalDialog method of Ui Class

    var html = HtmlService.createHtmlOutput("
    Hello world
    ").setSandboxMode(HtmlService.SandboxMode.IFRAME); DocumentApp.getUi().showModalDialog(html, "My Dialog");

    HtmlService.createHtmlOutputFromFile allows you to display html that is in a separate file. see the documentation

提交回复
热议问题