Tuesday 1 April 2008

Weirdnessin the IE DOM Event Model

Here is a werid if highly esoteric issue I discovered with IE, Well to be fair I didnt, Carl Tyler did when playing with my JS Name Picker Opentf project.

Now I make no secret of the fact I hate iFrames with a passion. I hate them so much I forgot to test the Name Picker App to see if they worked inside one in either IE or FF ....... it didn't in
F***ing IE and here is , as far as I can see the reason why.

I used synthesized events to load the various [divs] within the JS so the developer did not have to code them into the onLoad event of the form or page. Basically when onDomReady was triggered an Init() procedure was called that loaded up the bits and bobs needed for the name picker.

HOWEVER , when you put an iFrame on a page or form the IE event fires at a DOM level for both Parent and iFrame child. So if you override the onLoad event with a listener of your own
even though the code only exists in the iFrame document, it fires when the parent comes ready AND the again because IE thinks the iFrame is ready when it is not. This resulted in my bits and bobs being loaded in the parent and and error when the iFrame couldnt find document.body.

Thankfully it was easily got around for the moment (while i have a play the events and do some head scratching) by placing the INIT() call into the onload event of the iFrame source page. If you do this IE plays ball and does what you expect it to do.

Anyway it gave me an interesting evening and reinforced my belief that the people that coded IE could not find their arses with both hands and a map!


Nate said...

I have to confess, I'm a BIG fan of iframes. :-)

Steve McDonagh said...

You are?
Ye gods, how can you confess than and square it with your plans for world dominiation. You have the hair, you have the attitude BUT YOU LIKE iFRAMES???
I am shocked and stunned

VKI Studios said...

Is it
"that the people that coded IE could not find their arses with both hands and a map!"
or is it that they are being directed by a map developed by their strategies department and lawyers rather than by software engineers?

Disqus for Domi-No-Yes-Maybe