94
rated 0 times
[
99]
[
5]
/ answers: 1 / hits: 91346
/ 14 Years ago, sun, february 27, 2011, 12:00:00
How can I insert a script into HTML head dynamically using JavaScript?
More From » dynamic
How can I insert a script into HTML head dynamically using JavaScript?
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.onload = function() {
callFunctionFromScript();
}
script.src = 'path/to/your-script.js';
head.appendChild(script);