ui.alert 和 Browser.msgBox 有什么区别?
What's the difference between ui.alert and Browser.msgBox?
使用 Google 脚本时,有一个 Browser.msgBox();
(Link) and ui.alert();
(Link)。两者有什么区别?他们似乎在做完全相同的事情。
里面还有更多的方法,例如 Browser.inputBox();
和 ui.prompt();
,它们看起来是相同的。
浏览器 Class 仅适用于电子表格。 UiClass可以更广泛地使用。不幸的是, Class Ui 的文档仅显示了 getUi()
方法的示例 SpreadsheetApp Class。但是 getUi()
可用于 DocumentApp.
DocumentApp.getUi()
然后:
FormApp.getUi()
如果您尝试从错误的上下文中调用 Browser.msgBox()
,您将得到一个错误:
Cannot call Browser.msgBox() from this context; have you tried Logger.log() instead?
Browser.msgBox()
在电子表格脚本中更易于使用。您不需要先使用 var ui = SpreadsheetApp.getUi();
比较:
Browser.msgBox('prompt here');
SpreadsheetApp.getUi().prompt('prompt here');
使用 Google 脚本时,有一个 Browser.msgBox();
(Link) and ui.alert();
(Link)。两者有什么区别?他们似乎在做完全相同的事情。
里面还有更多的方法,例如 Browser.inputBox();
和 ui.prompt();
,它们看起来是相同的。
浏览器 Class 仅适用于电子表格。 UiClass可以更广泛地使用。不幸的是, Class Ui 的文档仅显示了 getUi()
方法的示例 SpreadsheetApp Class。但是 getUi()
可用于 DocumentApp.
DocumentApp.getUi()
然后:
FormApp.getUi()
如果您尝试从错误的上下文中调用 Browser.msgBox()
,您将得到一个错误:
Cannot call Browser.msgBox() from this context; have you tried Logger.log() instead?
Browser.msgBox()
在电子表格脚本中更易于使用。您不需要先使用 var ui = SpreadsheetApp.getUi();
比较:
Browser.msgBox('prompt here');
SpreadsheetApp.getUi().prompt('prompt here');