Dojo - Require 3rd party JS
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..
You could probably do something like
function require_js(href)
{
if (typeof href == 'undefined' || href.length == 0)
return false;
dojo.xhrGet({
url: href,
handleas : "javascript"
});
}
This should cause it to fetch the javascript at the url and eval it.
精彩评论