2017-08-25 41 views
0

我有這個不錯的谷歌應用程序腳本,工作正常,但它導致刪除我的谷歌電子表格中的工作表,因此我想腳本以一個是/否及時詢問「你確定要關閉這項工作嗎」。如果他說好,好的,繼續,如果不是,退出腳本。是/否用戶提示繼續或停止腳本

任何想法?提前致謝 !

回答

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.'); 
}