Reputation: 4917
I have the following Google Apps Script:
function popUp() {
const ui = SpreadsheetApp.getUi();
var message = "<HTML><BODY>"
+ "The meeting is at <b>10am</b>."
+ "</BODY></HTML>";
var popUP = ui.alert(message, ui.ButtonSet.OK);
}
When I apply this function to a button in my Google Sheets, the popup pops up as expected.
However, the text in the popup carries all the "messy" HTML coding.
How can I get the popup to show actual HTML formatted text?
In other words, how can I make the UI popup use the HTML-laden text I added for var message
but in a way that actually formats the text to use the HTML I added?
IS there some kind of HTML wrapper function?
What I get vs what I want:
Upvotes: 1
Views: 4388
Reputation: 64040
Here's a simple example closer to what you want. I don't think the alert takes html. It requires simple ascii text. Note: google.script.host.close()
doesn't work when deployed as a web app.
function popUp() {
var s='The meeting is at <strong>10:30AM</strong>.<br /><input type="button" value="OK" onClick="google.script.host.close();" />';
SpreadsheetApp.getUi().showModalDialog(HtmlService.createHtmlOutput(s), 'PopUp');
}
See this in the 'Custom Dialog' documentation for Apps Script: https://developers.google.com/apps-script/guides/dialogs
Upvotes: 3