Learning Google Apps Script
上QQ阅读APP看书,第一时间看更新

Creating a modal dialog

To create a modal dialog, which prevents the user from updating anything in the spreadsheet or document, update the code in the Code.gs file as shown here:

function onOpen(){
  DocumentApp.getUi()
  .createAddonMenu()
  .addItem("Show Dialog", "showDialog")
  .addToUi();
}

function showDialog() {
  var html = HtmlService
   .createHtmlOutputFromFile('Index');
  DocumentApp.getUi()   
   .showModalDialog(html, 'Greeting');
}

Go to Add-ons | Chapter 2 | Show Dialog and a modal dialog will pop up: