12

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?

7
  • 1
    Do you want to change google sites? I'm not sure I follow... Commented Jun 3, 2012 at 21:42
  • well i want use google sites, but a lot of the options and styling are unable to be changed by the usual settings, so I thought if i could ex execute a block of JS on the page, i could put in my own jQuery and change what i wanted to change. Commented Jun 3, 2012 at 21:45
  • Are you looking for GreaseMonkey? Chrome has built-in support for GreaseMonkey as well. Take a look at userscripts.org for some examples of what you can do. Commented Jun 3, 2012 at 21:46
  • I still don't get it, why would you want to change google site, like gmail for example. Commented Jun 3, 2012 at 21:47
  • 1
    no... google sites -> sites.google.com Commented Jun 3, 2012 at 21:48

3 Answers 3

11

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Yes i tried this first... didn't seem to work, let me try again.
As I noted, the capabilities of JS running in the Google Sites sandbox are restricted. Depending on what you're trying to do, you may or may not be able to do it. (In particular, if you're trying to modify content on the page that isn't part of the HTML box, you're out of luck.)
i tried putting this into the HTML, and no alert box showed : <script type="text/javascript"> alert('something'); </script>
I see, yeah then it wouldn't work. I want to change the height of ther nav-bar, location and size of navigation tabs... etc.
HTML box does not render with a <script> tag in there.
|
3

Another alternative is writing your own Gadget

"Gadgets are small web applications that can be added to web pages. Gadgets are XML files that typically wrap HTML and JavaScript" as explained by a Google Sites Guru that goes by the name Mori. https://sites.google.com/site/mori79/html-gadgets

You can also find more information in Google Developers site: https://developers.google.com/google-apps/sites/gadgets/site_gadgets?hl=en

Hope it helps.

1 Comment

Gadgets only work for Google Sites Classic, to be disabled in 2023. The new Google Sites doesn't have this any more.
2

Google Site has a good documentation, and you cannot use any JavaScript against their program policy.

Please read the documentation, it lists details of the steps for inserting custom CSS, JavaScript and general HTML.

4 Comments

The "program policy" link you grabbed there is for Docs, not Sites, and it's irrelevant to this question.
@duskwuff This is a general policy for hosting Google Sites as well as Google Docs. If you take a look the documentation for Google Site, they specifically link to this policy. So all your content, javascript, css, images should follow the same policy. The "alert" didn't work simply because it's against the policy. I did intentionally link to their doc instead of copying the steps, because their documentation might change over time, your copied content will not be able to keep up to date. This is NOT irrelevant. So please read it carefully before rating.
It's possible that we're actually seeing different versions of the policy page. The version I'm seeing doesn't mention JavaScript anywhere.
That link is just talking about violence, hate speech, child safety, etc. Absolutely nothing to do with Javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.