开发者

Dojo - Require 3rd party JS

开发者 https://www.devze.com 2023-04-10 23:04 出处:网络
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 loadi

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号