r9668: Cross-browser fix for IE, when adding scripts on the fly.
[sfrench/samba-autobuild/.git] / swat / scripting / client / js_scripts.js
index 776e5e4ded2f1b5e68459d2a003f73cf15418f39..1c6e5806f4cb3929ffb28206277a4a0e88155c29 100644 (file)
@@ -32,10 +32,17 @@ function __get_js_script(file)
 
 function __add_js_script(path)
 {
 
 function __add_js_script(path)
 {
+       // Create a unique ID for this script
+       var srcID = new Date().getTime();
+
        var script = document.createElement('script');
        var script = document.createElement('script');
-       script.setAttribute('type', 'text/javascript');
-       script.setAttribute('src', path);
+       script.type = 'text/javascript';
+       script.id = srcID;
+
        head.appendChild(script);
        head.appendChild(script);
+
+       // IE works only with the path set after appending to the document
+       document.getElementById(srcID).src = path;
 }
 
 function __remove_js_script(path)
 }
 
 function __remove_js_script(path)