1
|
// loadScript - Loads a single Javascript file into the browser
|
2
|
// Arguments:
|
3
|
// url - the address of the script file
|
4
|
// callback - called when the script has been loaded
|
5
|
var loadScript = (function(url, callback) {
|
6
|
if (callback == null) { callback = function() {}; }
|
7
|
// var head = document.getElementsByTagName("head")[0];
|
8
|
var body = document.getElementsByTagName("body")[0];
|
9
|
var script = document.createElement("script");
|
10
|
|
11
|
script.type = "text/javascript";
|
12
|
script.addEventListener("load", function() {
|
13
|
script.onLoad = null;
|
14
|
callback(script);
|
15
|
});
|
16
|
script.onLoad = function () {};
|
17
|
script.src = url;
|
18
|
// head.appendChild(script);
|
19
|
body.appendChild(script);
|
20
|
});
|
21
|
|