how to add custom javascript to google sites?

穿精又带淫゛_ 提交于 2021-02-04 10:58:27

问题


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:

  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.




回答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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!