在Google应用程序脚本中注入外部JavaScript文件(Google文档) [英] inject external javascript file in google app script(Google Docs)
问题描述
在此先感谢。
根据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屋!