how to add custom javascript to google sites?

jeffery_the_wind picture jeffery_the_wind · Jun 3, 2012 · Viewed 37.9k times · Source

How do I get the ability to add/edit the JS on a google sites site? This way I want to use jQuery and jQuery UI to manipulate the look and feel of the site.

To be clear, I am not talking about all google sites, just the create-your-own system google has made, called "Google Sites" -> https://sites.google.com/.

On the howto page, there is this: Unsupported features

The HTML Box tool currently doesn't support the following features:

iframes JavaScript code can't create any script, image or link tags Document/window onload and onready functions. You can place any JavaScript at the end of code that needs to load after the document loads.

Does that mean HTML tool cannot create tags? even though they are in the demo above?

Answer

duskwuff -inactive- picture duskwuff -inactive- · Jun 4, 2012

The Google Sites help explains how to add custom HTML/CSS/JS content:

  1. Go to the Google Sites page that you’d like to embed HTML in.
  2. Go to the Insert menu and select HTML Box.
  3. In the dialog that opens, add HTML, CSS and/or Javascript code.
  4. When you’re done, click Save.
  5. To preview your embedded HTML, click Save on the Google Site page.

It goes on to note that "code from one HTML box can’t interact with or refer to code outside of the HTML box, including other HTML boxes" -- presumably, each "HTML box" is a separately sandboxed iframe element. As such, your ability to use JS to "manipulate the look and feel of the site" will be pretty limited.