From 7c04a7f88a4c12bbe676aa399a731b6d49f0a90d Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Fri, 14 Dec 2007 20:48:19 +0000 Subject: [PATCH] tweaking the dynamic script tag adding bit (closes #1092). git-svn-id: http://svn.openlayers.org/trunk/openlayers@5411 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js index 91714594dd..6f83eaef1f 100644 --- a/lib/OpenLayers.js +++ b/lib/OpenLayers.js @@ -179,15 +179,16 @@ "OpenLayers/Control/EditingToolbar.js" ); // etc. - - - var allScriptTags = ""; - var host = OpenLayers._getScriptLocation() + "lib/"; - + var agent = navigator.userAgent; + var docWrite = (agent.match("MSIE") || agent.match("Safari")); + if(docWrite) { + var allScriptTags = new Array(jsfiles.length); + } + var host = OpenLayers._getScriptLocation() + "lib/"; for (var i = 0; i < jsfiles.length; i++) { - if (/MSIE/.test(navigator.userAgent) || /Safari/.test(navigator.userAgent)) { - var currentScriptTag = ""; - allScriptTags += currentScriptTag; + if (docWrite) { + allScriptTags[i] = ""; } else { var s = document.createElement("script"); s.src = host + jsfiles[i]; @@ -197,8 +198,8 @@ h.appendChild(s); } } - if (allScriptTags) { - document.write(allScriptTags); + if (docWrite) { + document.write(allScriptTags.join("")); } } })();