Editing HTML content in Google Sites
I have a small project in mind but cant seem to get past this one obstacle. Having trouble getting the HTML content of this Google Sites Page and adding a single line too it. So if one would keep refreshing the page the 'Hello World' line would keep adding itself over and over. I have noticed that the original code that embeds the gadget gets altered quite a bit too.
function doGet() {
var app = UiApp.createApplication();
var page = SitesApp.getActivePage();
var html = page.getHtmlContent();
var main = page.setHtmlContent(html + '<br>Hello World<br>');
return app;
}
.getHtmlContent()
will return all the html markup and tags. So, you're trying to set "Hello World" after all the tags have been closed.
Throw a Logger.log(html);
in there to see what you need to get at and change. Ultimately you'll need to replace the text you want within the html instead of just adding a line to the end.