如何将JavaScript代码嵌入Google协作平台页面? [英] How do I embed JavaScript code into a Google Sites page?

查看:115
本文介绍了如何将JavaScript代码嵌入Google协作平台页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Google协作平台页面。如何在其中嵌入JavaScript代码,而无需实现小工具并在其中添加JavaScript代码?

I have a Google Sites page. How can I embed JavaScript code in it, without implementing a gadget and adding JavaScript code in that?

推荐答案

您可以运行一些JavaScript代码,但在页面编辑过程中它将自动包装到一个普通的小工具中,当渲染页面时它将在iframe内部执行,将无法与主页的DOM交互页面 - 浏览器和Google协作平台的安全机制阻止了这种情况。

You can run some JavaScript code, but during page editing it will be automatically wrapped into a trivial gadget, and when rendering page it will be executed inside of iframe, and won't be able to interact with DOM of main page - this is prevented by security mechanisms of browser and Google Sites.

所以,你的脚本所做的任何事情,它都会在它的iframe的沙箱中进行,如果你不想实现,那么在页面设计时定义外部大小小工具。

So, anything your script do, it will do in a sandbox of it's iframe, who's outer size is defined at page design time, if you don't want to implement a gadget.

即使您在里面使用脚本实现小工具,它也会在同一个iframe沙箱中运行。但小工具有一些优势,例如访问API,允许动态更改iframe的大小,以及其他一些。

And even if you implement a gadget with your script inside, it will also run in the same iframe sandbox. But gadget has some advantages, for example access to API, that allows to change size of iframe dynamically, and some others.

这篇关于如何将JavaScript代码嵌入Google协作平台页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆