[v3.6] IE8 - Javascript error

608
1
09-10-2013 01:04 AM
YannickFusulier
New Contributor
Hello,

I'm having an issue with IE8. I have downloaded and installed in my web application the version 3.6 of the javascript API. Once I have configured the files as described in the install.html provided with the API, I have tried to run the sample code.
This is the error I get when running the page

[ATTACH=CONFIG]27309[/ATTACH]

All URLs are are valid and can be reached.
Here is the page's code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
  <head>
      <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Simple Map</title>
    <link rel="stylesheet" type="text/css" href="http://myipandmyport/acap/arcgis_js_api/library/3.6/3.6/js/dojo/dijit/themes/tundra/tundra.css"/>
    <link rel="stylesheet" type="text/css" href="http://myipandmyport/acap/arcgis_js_api/library/3.6/3.6/js/esri/css/esri.css" />
    <script type="text/javascript" src="http://myipandmyport/acap/arcgis_js_api/library/3.6/3.6/init.js"></script>

    <script type="text/javascript">

      dojo.require("esri.map");

      function init() {
        var myMap = new esri.Map("mapDiv");
        //note that if you do not have public Internet access then you will need to point this url to your own locally accessible cached service.

        var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer");

        myMap.addLayer(myTiledMapServiceLayer);

      }

      dojo.addOnLoad(init);

    </script>

  </head>

  <body class="tundra">
    <div id="mapDiv" style="width:900px; height:600px; border:1px solid #000;"></div>

  </body>



When I replace the following line
<script type="text/javascript" src="http://myipandmyport/acap/arcgis_js_api/library/3.6/3.6/init.js"></script>

by
<script src="http://js.arcgis.com/3.6/"></script> 

I don't get the error.
I have compared the files of the two URLs and there are the same (except for the server and port config).

The code works with Chrome/Firefox/IE10.

I have tried to download several times the API (in case of download related issues) and it is always the same.

Do you have any idea?

Thank you.
Yannick.
0 Kudos
1 Reply
MatthewLofgren
Occasional Contributor
IE8 doesnt always seem to be ready when dojo/ready or addOnLoad is called.

The differences between your local copy of the jsapi and the hosted one is probably latency allowing IE8 to be more ready.

Try wrapping your map initialization in a timeout. I've had to do similar things before.


function init() {
setTimeout(function () {
        var myMap = new esri.Map("mapDiv");
        //note that if you do not have public Internet access then you will need to point this url to your own locally accessible cached service.

        var myTiledMapServiceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/NGS_Topo_US_2D/MapServer");

        myMap.addLayer(myTiledMapServiceLayer);
}, 10);
      }
0 Kudos