IE background CSS and onclick/onmousedown

2007-08-04 09:36:00

I recently fixed an IE-only bug in Chandler Server that resulted from moving the base listener for some event delegation code from the body to another node lower down in the DOM tree.

Interesting that I've never tripped over this before, because it's so totally glaring -- but in IE (both IE6 and IE7), absolute-positioned block elements that have no background set (i.e., no background, background-color, or background-image) do not trigger click or mousedown DOM events.

I haven't done any extensive testing to see what all is out of whack there, but I do have a minimal test page that shows the basic behavior in action.

If you happen to have a VM already running and IE fired up, go take a look. The div on the left has no background-color specified. The one on the right does. Otherwise they're identical. Click on the left one, you get bupkis. Click on the right one, you get a JS alert box.

Setting the the background value to transparent has the same effect. (Or non-effect, should I say?)

I'm belaboring the obvious but if IE were an open-source project, I'd go to their bug tracker and look to see if someone else has already reported this. As it is, the public bug database for IE7 is 'temporarily closed,'. For whatever value of 'temporarily.'

The IE guys have done a lot of stuff right -- turning off their public bug database is not one of them.


scottb (2007-08-08)

Interesting catch, I haven’t noticed it either.

But if you actually click exactly on the ‘Border’ you then get the Click Event.


This is the blog for Matthew Eernisse. I currently work at Yammer as a developer, working mostly with JavaScript. All opinions expressed here are my own, not my employer's.


Previous posts

All previous posts ยป

This blog is a GeddyJS application.