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

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

问题描述

请告诉我如何在谷歌应用脚​​本(谷歌文档)中注入外部 javascript 文件.

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

提前致谢.

推荐答案

根据您所说的 Inject,一个可能的答案是使用标准的 javascript eval() 函数和 UrlFetchApp:

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());

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

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>

评估文档:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/evalUrlfetchApp 文档:https://developers.google.com/应用程序脚本/参考/url-fetch/url-fetch-app

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

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

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