IE DOM updating (or, the Worlds most obscure bug).
Spent the last few days wrestling with what I can safely say is the most obscure bug I’ve ever had the pleasure of trying to track down.
I had a flash player wrapped in a jquery/html/css wrapper that I was embedding in a page that was working fine in my development environment but when I tried to put it on a page with content the flash was failing to embed in all the versions of IE that I tried.
So, I started stripping out content until I got a working player and then trying to figure out what bits of content were actually causing it to fail. Here’s what I found:
- If there was an <img> tag on the page with a src attribute that linked to an external source (ie, http:// followed by even a single character) it would fail.
- If the img src attribute was linked to an internal image it would work fine unless the content also contained an <li> element embedded within a <ul> (it wouldn’t break if the <li> was embedded in a <ol> or if the <ul> was just empty).
As of now, I still have utterly no idea what was going on, but I managed to actually fix it with an ugly hack of wrapping the flash embed section of the code in a setTimeout function going on a theory that IE was looking at other parts of the DOM when it should have been concentrating on the embed.
setTimeout(function() {
swfobject.embedSWF(url,
$container.attr('id'), config.flashWidth,
config.flashHeight, "9", null, flashvars, params, atts);
}, 0);
This seemed to work, as the player now loads fine in IE in all my test environment as well as the live site I first discovered the bug on. It’s been a strange and frustrating few days though and frankly I’d feel a lot better if I knew for sure what on earth was going on.
Category: Web Development Comment »