问题
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?
回答1:
The Google Sites help explains how to add custom HTML/CSS/JS content:
- Go to the Google Sites page that you’d like to embed HTML in.
- Go to the Insert menu and select HTML Box.
- In the dialog that opens, add HTML, CSS and/or Javascript code.
- When you’re done, click Save.
- 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.
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/10874147/how-to-add-custom-javascript-to-google-sites