This is working on modern browsers, but it is not loading jQuery on IE <= 9.0.
Here is the code in the index.html file:
loadJQuery(function () {
alert('hello');
});
And then on another file (included via <script src>
) I have:
if (typeof(loadJSInclude) == 'undefined') {
function loadJSInclude(scriptPath, callback)
{
var scriptNode = document.createElement('SCRIPT');
scriptNode.type = 'text/javascript';
scriptNode.src = scriptPath;
var headNode = document.getElementsByTagName('HEAD');
if (headNode[0] != null)
headNode[0].appendChild(scriptNode);
if (callback != null)
{
scriptNode.onreadystagechange = callback;
scriptNode.onload = callback;
}
}
function loadJQuery(task) {
if (typeof(jQuery) == "undefined") {
loadJSInclude('http://code.jquery.com/jquery-latest.min.js', function() {
$(document).ready(task)
});
} else {
$(document).ready(task);
}
}
}
Any idea on why that would not work on IE <= 9.0? I tried adding many alerts to loadJQuery function, and they are all displaying, and my guess is that I am incorrectly adding the node to the head element for the old IEs.