Tag Archives: IE8

jQuery, OpenLayers.Layer.Vector and IE8

One of the very first things you learn about OpenLayers is the importance if initializing maps in either the body tag’s onload event or in script tags at the bottom of the page. The basic reason for this is that many of the OpenLayers components need a page’s dom to be complete before it starts adding it’s own dom structure. The onload event is thrown after the browser is finished loading everything else, and the bottom of the page naturally gets rendered last, so these two places tend to work the best. Makes sense right?

If you’ve been using additional frameworks, like  jQuery ( or EXT or Django or Drupal or whatever) you’ve learned to rely on that framework’s onready event, or its rough equivalent.  This event tends to be thrown before the onload event so that the frameworks don’t need to wait for every last image and tag to be loaded. In theory, this could be a very problematic place to put OpenLayers map initialization code. The dom elements that OpenLayers is looking for may or may not be there, and there’s no way to tell. In practice, most browsers, and most OpenLayers components, work fine when initialized in a framework’s onready event. One layer in particular (OpenLayers.Layer.Vector) will not play nice with one particular browser (IE8) if initialized in a framework’s onready event. The vector layer depends on the document object’s namespace attribute, and this attribute simply isn’t always available before IE’s onload event (which is called after the onready event). As you can imagine, this was one headache I wish I could have avoided.

Thankfully, there is a fairly simple fix. Instead of the usual convention of :

$.ready(function() { init_my_map(); });

Add a stand-alone script tag to the extreme end of the body content on the pages where you need a vector layer:

<script>
    init_my_map();
</script>

IE8 Menu Control – Skip Navigation Link Bug

Skip navigation links are a good thing, even if your average user can’t see them. They can become a bad thing if your layout assumes that they’re not visible to sighted users of IE8. For some of my menus, (and I don’t know why one does and the others don’t) there’s this annoying space at the top. Using IE8′s marvelously upgraded debugger, I can see that it’s a skip link… with height and width of 0 pixels… that’s still showing up? How??

After much fruitless searching, I found a lonely little forum entry from last year that offers the following one-line fix:

SkipLineText=”"

Put that line in the menu tag declaration or the skin file and you’re golden… unless you can’t see. Then there’s unfortunately nothing for your screenreader to read. *sigh* Hopefully this little ‘feature’ gets an official patch soon.