always use "parser-inserted scripts" for guaranteed execution order, thanks a lot hsivonen for reporting this and the thorough explanations, r=pgiraud (closes #2933)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11036 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2011-01-17 14:37:15 +00:00
parent 3795dbf490
commit 7b5718f9ac
2 changed files with 350 additions and 18 deletions

View File

@@ -314,28 +314,15 @@
"OpenLayers/Lang/en.js"
); // etc.
var agent = navigator.userAgent;
var docWrite = (agent.match("MSIE") || agent.match("Safari"));
if(docWrite) {
var allScriptTags = new Array(jsfiles.length);
}
// use "parser-inserted scripts" for guaranteed execution order
// http://hsivonen.iki.fi/script-execution/
var allScriptTags = new Array(jsfiles.length);
var host = OpenLayers._getScriptLocation() + "lib/";
for (var i=0, len=jsfiles.length; i<len; i++) {
if (docWrite) {
allScriptTags[i] = "<script src='" + host + jsfiles[i] +
allScriptTags[i] = "<script src='" + host + jsfiles[i] +
"'></script>";
} else {
var s = document.createElement("script");
s.src = host + jsfiles[i];
var h = document.getElementsByTagName("head").length ?
document.getElementsByTagName("head")[0] :
document.body;
h.appendChild(s);
}
}
if (docWrite) {
document.write(allScriptTags.join(""));
}
document.write(allScriptTags.join(""));
}
})();