Mwsmurf
Mwsmurf

Reputation: 21

Set Google Apps Script Background in Google sites

I've run into an issue with embedding a Google Apps Script HTML into my Google Site in that the default white background doesn't fit with the theme of the website.

Is it at all possible to get the Google Apps Script HTML to have a transparent background or change the background colour of the Google Apps Script to suite it more? I've done alot of research but I have yet to find anyone who has found a solution to this issue.

Upvotes: 1

Views: 894

Answers (1)

Wicket
Wicket

Reputation: 38140

By default, HtmlElements have a transparent background, but Google Apps Script web app embeds the content generated by the HtmlService in an iFrame which has an element with the background set as white. This element can't be accessed from Google Apps Script.

The workaround is to inspect the Google Sites page that will contain the embedded element and set the background color of the Google Apps Script web app to that color. Let say that your site has a green background, the following shows one way to set the background color of the body element of the Google Apps Script web app to green:

Code.gs

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('index');
}

index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
    <style>
      body {
        background-color: green;
      }
    </style>
  </head>
  <body>
    <p>Hello world!</p>    
  </body>
</html>

Related

Upvotes: 1

Related Questions