Dojo - 需要第 3 方 JS
我正在使用 Dojo 1.6。
在我的一个自定义 Javascript 文件中,我需要包含另一个自定义 JS 文件。我不想将它作为 JS 模块或类似的东西加载,我只是希望它加载,就好像它是通过内联脚本标签完成的一样。
有谁知道如何做到这一点?
预先感谢,
编辑:
我已经尝试使用覆盖的 dojo.require 来不检查它是否存在等,但它似乎想要修改路径..我无法让它在 js 文件夹之外查看..
编辑:
与很多事情一样,现在我已经把它写下来了,我已经得到了一个解决方案..(我实际上用于类似的 CSS 查询)..
function require_js(href)
{
if (typeof href == 'undefined' || href.length == 0) return false;
var script = dojo.create("script", { src:href, type:"text/javascript" }, "");
dojo.doc.getElementsByTagName("head")[0].appendChild(script);
}
有没有更好的方法来做到这一点?
再次感谢..
I am using Dojo 1.6.
In one of my custom Javascript files i have the need to include another custom JS file. I do not wish to load it as a JS module or anything like that, i would just like it loading as if it was done with script tags inline..
Does anyone know how to do this?
Thanks in advance,
EDIT:
I have tried a dojo.require using the overrides for it not to check it exists etc, but it seems to want to modify paths.. I cant get it to look outside of the js folder..
EDIT:
As with alot of things it seems, now that i've written it down, i've gotten a solution.. (One i used for a similar CSS query actually)..
function require_js(href)
{
if (typeof href == 'undefined' || href.length == 0) return false;
var script = dojo.create("script", { src:href, type:"text/javascript" }, "");
dojo.doc.getElementsByTagName("head")[0].appendChild(script);
}
Is there a better way of doing this?
Thanks again..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能可以执行类似的操作
,这应该会导致它在 url 处获取 javascript 并对其进行评估。
You could probably do something like
This should cause it to fetch the javascript at the url and eval it.