开发者

Loading JS dynamically from another JS (jQuery)

I'd like to know if I can load an external JS dynamically based on some condition, for example:

$(window).load(function () {
   if($.browser.msie && $.browser.version=="6.0") {
     // load ie.js
     // do stuf开发者_如何学Pythonf using ie.js
   }
});


JQuery's GetScript should do it.

$.getScript("yourscirpt.js", function() {
    alert('Load Complete');
});


If not using jquery, use this to include js

document.writeln('<script type="text/javascript" src="your.js"></script>');


Use $.getScript(url,callback); it loads the script, and executes it.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜