Monday, May 20, 2024
95
rated 0 times [  101] [ 6]  / answers: 1 / hits: 23054  / 10 Years ago, mon, october 13, 2014, 12:00:00

I am trying to create a web app using Google app script, that if you press a button, you may get an alert message.



In the home.gs file I tried this :



function let_user_decide()
{
Browser.msgBox('Greetings', 'Press Yes or No?', Browser.Buttons.YES_NO);
};


unfortunately I keep getting this when I press the button when I should get the alert message :




Exception: Cannot call Browser.inputBox() from this context.




Important to mention : my script is using Google spreadsheet but the msgBox should appear in the webapp! In addition, I use HTML



Any idea what am I doing wrong? And how can I fix it?


More From » google-apps-script

 Answers
43

Browser.msgBox is indeed only available in the spreadsheet interface, not in webapps.



You have a lot of alternatives to throw alerts but you should mention wether you use UiApp or HTML Service.



In UiApp you can create a popupPanel for example while in HTML you can throw alerts (throw new Error('sample alert')) or use JQuery Ui elements to do that.


[#69145] Friday, October 10, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rey

Total Points: 415
Total Questions: 100
Total Answers: 100

Location: Croatia
Member since Fri, Sep 11, 2020
4 Years ago
;