Loading Multiple Scripts With Document.write
I want to load 2 external JS scripts within a script tag, is there a way to load 2 scripts with one document.write tag or do you have to declare it twice? Can't seem to find any an
Solution 1:
document.write('<scriptsrc="js/scroll.js"><\/script><scriptsrc="js/mobile.js"><\/script>');
Solution 2:
Check out this way:
//JS CODE:functioninclude(path)
{
var e;
e = window.document.createElement('script');
e.setAttribute('src',path);
window.document.body.appendChild(e);
}
include("js/scroll.js");
include("js/mobile.js");
Solution 3:
Can you use jQuery?
jQuery("document").ready(function() {
if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod'){
document.write('<script src="js/scroll.js"><\/script><script src="js/mobile.js"><\/script>');
}
});
Post a Comment for "Loading Multiple Scripts With Document.write"