notes on javascript, linux, and more


IE6 peek-a-boo bug

I was trying to manipulate the DOM to workaround the IE6 peekaboo bug, but none of the recommended methods seemed to work. I thought up this neat trick:

<!-- elijahr peekaboo fix -->
<img src="" alt="" style="display:none" onload="javascript:this.parentNode.innerHTML=this.parentNode.innerHTML+' ';"/>

It basically just rebuilds the corrupted DOM section through javascript and forces IE 6 to render correctly. You can put it only in the places you need it, or right under the body tag. Just make the img element a child of whatever element is giving you issues. A broader, but somewhat slower approach that might work would be to simply set the onload event of the body tag to:

<body onload="javascript:this.innerHTML=this.innerHTML+' ';">

But, that might not work in every case. Peek-a-boo is a sneaky fiend of a bug.


1 comment:

elijahr said...

Well, this doesn't seem to work when I apply it to the HTML with the most clearcut example of Peek-a-boo that I could find - So, I'm not exactly sure why it worked in the scenario that I was using it (it did indeed work there), but perhaps somebody will find it useful anyways.

About Me

My photo
chicago, il, United States
I'm a software engineer by profession.