OpenLayers OpenLayers

Changeset 5411

Show
Ignore:
Timestamp:
12/14/07 15:48:19 (1 year ago)
Author:
tschaub
Message:

tweaking the dynamic script tag adding bit (closes #1092).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/openlayers/lib/OpenLayers.js

    r5410 r5411  
    180180        ); // etc. 
    181181 
    182  
    183  
    184         var allScriptTags = ""; 
    185         var host = OpenLayers._getScriptLocation() + "lib/"; 
    186      
     182        var agent = navigator.userAgent; 
     183        var docWrite = (agent.match("MSIE") || agent.match("Safari")); 
     184        if(docWrite) { 
     185            var allScriptTags = new Array(jsfiles.length); 
     186        } 
     187        var host = OpenLayers._getScriptLocation() + "lib/";     
    187188        for (var i = 0; i < jsfiles.length; i++) { 
    188             if (/MSIE/.test(navigator.userAgent) || /Safari/.test(navigator.userAgent)) { 
    189                 var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";  
    190                 allScriptTags += currentScriptTag; 
     189            if (docWrite) { 
     190                allScriptTags[i] = "<script src='" + host + jsfiles[i] + 
     191                                   "'></script>";  
    191192            } else { 
    192193                var s = document.createElement("script"); 
     
    198199            } 
    199200        } 
    200         if (allScriptTags) { 
    201             document.write(allScriptTags); 
     201        if (docWrite) { 
     202            document.write(allScriptTags.join("")); 
    202203        } 
    203204    }