views:

110

answers:

0

I have a problem with dojo.xhrGet (dojo 1.3) in IE8 where:
1. I have a set javascript files that must satisfy some dependecies proj4js.js depends on OLprototype.js
while lcc.js and EPSG3308.js are needed if proj4js.js is used.
2. if I execute the script below, funLoad("/proj4js/lib/proj4js.js") fails on IE8, while it works on FF3.6.3; funLoad uses dojo.xhrGet with javascript handleAs param
3. To make it work on IE8, I have to use funLoadText (which retrieves javascript as text), concatenate the scripts and then eval them.

Am I missing something or is this dojo's problem ?

<script type="text/javascript">
    // handleAs javascript
var funLoad = function(javascriptUrl) {                
    dojo.xhrGet({url:javascriptUrl,sync:true,handleAs:"javascript", 
                load: function (data) {debugger;
                    console.log("success funLoad" + data);
                },
                error: function (err) {
                    console.log("error funLoad");
                }
        });
};

    // handleAs text
var funLoadText = function(javascriptUrl) {
    var returnscript;
    dojo.xhrGet({url:javascriptUrl,sync:true,handleAs:"text", 
                load: function (data) {debugger;
                    returnscript = data;
                    console.log("success funLoad" + data);
                },
                error: function (err) {
                    console.log("error funLoad");
                }
        });
    return returnscript;
}
</script>

<script type="text/javascript">

    // Block1, only works for FF3.6.x   
funLoad("/proj4js/lib/OLprototype.js");
funLoad("/proj4js/lib/proj4js.js"); // -------> this line fails on IE8
funLoad("/proj4js/lib/projCode/lcc.js");
funLoad("/proj4js/lib/defs/EPSG3308.js");

    // Block2, works on both IE8 and FF3.6.x
var js1 = funLoadText("/proj4js/lib/OLprototype.js");
var js2 = funLoadText("/proj4js/lib/proj4js.js");
var js3 = funLoadText("/proj4js/lib/projCode/lcc.js");
var js4 = funLoadText("/proj4js/lib/defs/EPSG3308.js");
var thescript = js1 + "\n" + js2 + "\n" + js3 + "\n" + js4; 
eval(thescript); // --> this works for both IE8 and FF3.6.x

</script>