OpenLayers OpenLayers

Changeset 1540

Show
Ignore:
Timestamp:
10/03/06 10:11:43 (2 years ago)
Author:
crschmidt
Message:

If we're not running under IE, we should append script tags via the DOM.
This works in Safari, Firefox, Opera, and we check for IE and do it the old
way for them. Closes #177 .

Files:

Legend:

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

    r1525 r1540  
    109109 
    110110    for (var i = start; i < jsfiles.length; i++) { 
    111         var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";  
    112         allScriptTags += currentScriptTag; 
     111        if (/MSIE/.test(navigator.userAgent)) { 
     112            var currentScriptTag = "<script src='" + host + jsfiles[i] + "'></script>";  
     113            allScriptTags += currentScriptTag; 
     114        } else { 
     115            var s = document.createElement("script"); 
     116            s.src = host + jsfiles[i]; 
     117            var h = document.getElementsByTagName("head").length ?  
     118                       document.getElementsByTagName("head")[0] :  
     119                       document.body; 
     120            h.appendChild(s); 
     121        } 
    113122    } 
    114     document.write(allScriptTags); 
     123    if (allScriptTags) document.write(allScriptTags); 
    115124    })(); 
    116125}