I am serving the following files from a the same directory on localhost:


map.html simply creates an OpenLayers map and displays the KML file as per the OpenLayers example. I access it via http://localhost:8080/map.html and it all works fine in Firefox and Chrome but not in IE. In IE I get the navigation buttons but no map. The OpenLayers example does work in IE...

The contents of map.html are shown below:

<script src="OpenLayers.js"></script>
<div style="width: 100%; height: 100%" id="map"></div>
<script defer="defer" type="text/javascript">      

var map = new OpenLayers.Map('map');

  <!-- Add background map -->  
    var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
        "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );

    <!-- Add kml layer -->  
    var kml = new OpenLayers.Layer.Vector("KML", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.HTTP({
            url: "output.kml",
            format: new OpenLayers.Format.KML({
                extractStyles: true, 
                extractAttributes: true,
                maxDepth: 2

    <!-- Zoom -->
    kml.events.register("loadend", kml, function (e) {


Any ideas?

2 Answers 2


I think you might have an error in the javascript code which is only triggered by IE. To better understand what's going on in IE I recommend you install the Developer Toolbar, available as a free add-on from Microsoft:


IE9 should already have it installed by default.

After installing the IE Developer Toolbar open it by pressing F12 and then look for errors in the javascript console.

Alternatively you can comment out portions of code starting from kml.events.register and see if that fixes it.

Updated after comment

IE chokes because the web server does not return application/xml as the content type. Use the dev toolbar to confirm (inspect network traffic).

To fix configure files with .kml extension as application/xml into your web server configuraion.

  • It is the KML Vector layer that breaks IE. It's an unknown Javascript error and from what I have read may be related to IE's same origin policy, even though the KML, HTML and javascript are hosted on the same server.
    – user8204
    Commented Jun 14, 2012 at 14:54
  • I have updated the answer as per your comment
    – unicoletti
    Commented Jun 14, 2012 at 18:10
  • I added the mime mapping to jetty but still got the same issue: SCRIPT16389: Unspecified error. OpenLayers.js, line 2589 character 96.
    – user8204
    Commented Jun 18, 2012 at 8:13
  • Could you make the map publicly available so that we can look at at it?
    – unicoletti
    Commented Jun 18, 2012 at 10:52

Could this be because of the 'loadend' event? I think it does have issues with IE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.