Reputation: 68790
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 stuff using ie.js
}
});
Upvotes: 1
Views: 765
Reputation: 6841
If not using jquery, use this to include js
document.writeln('<script type="text/javascript" src="your.js"></script>');
Upvotes: 3
Reputation: 29749
Use $.getScript(url,callback)
; it loads the script, and executes it.
Upvotes: 0
Reputation: 27926
JQuery's GetScript should do it.
$.getScript("yourscirpt.js", function() {
alert('Load Complete');
});
Upvotes: 4