0

在我第一次使用 Google 脚本时,我试图定义一个调用 Browser.input 方法来获取用户名的函数。但我总是收到以下错误消息:

不允许从此上下文调用 Browser.inputBox()。

(我必须说我已经从葡萄牙语环境中翻译了它,因为这种情况在英语中有不同的表达方式)。

如果有人可以建议我,我将不胜感激。谢谢。

4

1 回答 1

1

Browser.inputBox() can only be used from a script running from a spreadsheet. Once you use a Ui (with UiApp or GUI builder or HTML service) you can't use these Browser methods. The only situation in wich they can be combined is when you show(app) from a spreadsheet script but then the Browser call will close the UI immediately.

This seems quite logical since they are in a way Ui themselves...

By the way, you say in your comment that you are updating your question with some code but I see nothing ? Is it normal ?


EDIT : to answer your comment, there are many ways to interact with users... something that is quite similar to Browser.message is the popup example proposed by Waqar Ahmad recently. As for your second point : where to find such information... well I guess I've read about everything that can be read on the subject for quite a moment now.... I'm not sure where that particular aspect is described, sorry about that. If you read Google documentation about Ui I'm pretty sure you'll find something about that. (maybe someone from the team could help me on that point ? ;-)

于 2012-12-01T11:03:06.713 回答