To add an HTML file to your Apps Script project, follow these steps:
https://developers.google.com/apps-script/guides/html
- Open the Apps Script editor.
- At the left, click Add a file add > HTML.
<!DOCTYPE html> <html> <head> <base target="_top"> <script> function readSSContents() { //simply call a funcion in script var ssContents = google.script.run.myFunction() } function onSuccess(numUnread) { var div = document.getElementById('output'); div.innerHTML = 'You have ' + numUnread + ' unread messages in your Gmail inbox.'; } function getSSContents() { // call function and get return values google.script.run.withSuccessHandler(onSuccess) .myFunction(); } </script> </head> <body> Hello World <input type="button" value="showSSContents" onclick="getSSContents()" /> <input type="button" value="Close" onclick="google.script.host.close()" /> <div id="output"></div> </body> </html>
- and in Code.gs
https://developers.google.com/apps-script/guides/html/communicationfunction doGet() { return HtmlService.createHtmlOutputFromFile('Index'); }
- Once that basic framework is in place, all you have to do is
save
a version of your script, thendeploy
your script as a web app.
|
|