Ticket #2277 (closed feature: fixed)

Opened 4 years ago

Last modified 2 years ago

Openlayers in an UpdatePanel with IE8 gets: htmlfile: Invalid argument

Reported by: glink Owned by: crschmidt
Priority: minor Milestone: 2.11 Release
Component: Control.PanZoom Version: 2.8
Keywords: Cc:
State: Awaiting User Feedback

Description

Is there a known issue with trying to use OpenLayers in a .net UpdatePanel with IE8? I am trying to have an openlayers map in an UpdatePanel with IE8 and get the message htmlfile: Invalid argument on line 237 of PanZoomBar.js when returning to the previous page.

line 237 has: this.div.removeChild(this.zoombarDiv);

I get this error the same number of times as partial post backs occurred on the page with the map. I'm using OpenLayers 2.8. My code works fine with FireFox.

Attachments

openlayers-2277.patch Download (0.5 KB) - added by ahocevar 4 years ago.

Change History

Changed 4 years ago by ahocevar

I can confirm that this also happens in IE7 when destroying a map in a GeoExt application. Probably a general destroy issue.

Changed 4 years ago by ahocevar

  • owner set to crschmidt
  • component changed from general to Control.PanZoom

Changed 4 years ago by ahocevar

Changed 4 years ago by ahocevar

  • state set to Awaiting User Feedback

The patch attached above should fix the issue. glink, can you please confirm if that works for you?

Changed 4 years ago by ahocevar

I just investigated this issue a bit more, and here is what I found:

If an OpenLayers.Map instance lives inside a container that is cleaned up by someone else (in my case Ext JS), it is very important to destroy the Map instance before that cleanup happens. Otherwise the page unload handler of OpenLayers, which destroys the map, will find a dom that is already removed, and fail in several places.

I bet that glink is also running into this issue, and that his .net application is cleaning up the dom before OpenLayers runs its page unload handler.

So what probably will happen is: the patch above will fix the PanZoomBar issue, but other issues will appear until the rule described above is obeyed.

As a reminder, here is the situation in GeoExt / Ext JS that makes page unload fail:

var map = new OpenLayers.Map();
var mapPanel = new GeoExt.MapPanel({
    map: map // will render the map inside an Ext.Panel container
});

mapPanel.destroy();

// now page unload will fail because the map instance still lives, and
// map.destroy() will fail because its dom was destroyed by the Ext.Panel.

And here is what works:

var map = new OpenLayers.Map();
var mapPanel = new GeoExt.MapPanel({
    map: map // will render the map inside an Ext.Panel container
});

map.destroy(); // destroy the map before its dom gets destroyed
mapPanel.destroy();

// now page unload will work fine, because the OL.Map instance is
// already destroyed when Ext.Panel destroy the dom.

Changed 2 years ago by crschmidt

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.