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.
精彩评论