在Google应用程序脚本中注入外部JavaScript文件(Google文档) [英] inject external javascript file in google app script(Google Docs)

查看:113
本文介绍了在Google应用程序脚本中注入外部JavaScript文件(Google文档)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在此先感谢。

解决方案

根据Inject的含义,一个可能的答案是使用标准的JavaScript eval()函数和UrlFetchApp:

  eval(UrlFetchApp.fetch('http://path.to/external/javascript.js').getContentText()); 

如果您想在已发布脚本的HTML输出中包含JS文件,只需包含javascript在你的HTML中使用标签。

 < script src =http://path.to/external/javascript.js>< / script> ; 

评估文档:
UrlfetchApp文档:
https://developers.google。 com / apps-script / reference / url-fetch / url-fetch-app

Please let me know how to inject external javascript file in google app script(Google Docs).

Thanks in advance.

解决方案

Depending on what you mean by Inject, one possible answer is to use the standard javascript eval() function along with UrlFetchApp:

eval(UrlFetchApp.fetch('http://path.to/external/javascript.js').getContentText());

If you want to include a JS file in the HTML output of a published script, simply include the javascript using tags in your HTML.

<script src="http://path.to/external/javascript.js"></script>

Eval docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval UrlfetchApp docs: https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app

这篇关于在Google应用程序脚本中注入外部JavaScript文件(Google文档)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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