Joys of Cross-Browser Development
In FF, change is fired when:
- You hit enter after tabbing into the select and changing its value
- You tab out of the field after changing its value with the up and down arrows
- You mouse click on the select, then click on an entry in the pop up list
This is sensible, even if it does not, perhaps, match the spec.
In IE 6:
- After using the mouse to select a value from the popup
- After changing the value with the up and down arrows
In other words, any visual change to the select causes an immediate change event. Of course, I need to work around IE's behavior since it will result in way too many Ajax requests. My event handler needs to set a timer and wait some time, perhaps 1/4 seconds, before doing the Ajax update (but only if another change event hasn't been triggered). Fortunately, I have Prototype's delay on my side.
Meanwhile, who implements the spec correctly? Here's what it says:
The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus. This attribute applies to the following elements: INPUT, SELECT, and TEXTAREA
So, when using mouse selection, FF fires early (before the tab out of the field, or when you hit enter), and IE fires early all the time.
And for those who have asked ... yes, I'll "productize" this code and put it into Tapestry 5.2!
From http://tapestryjava.blogspot.com
Creator of the Apache Tapestry web application framework and the Apache HiveMind dependency injection container. Howard has been an active member of the Java community since 1997. He specializes in all things Tapestry, including on-site Tapestry training and mentoring. Howard is a DZone MVB and is not an employee of DZone and has posted 18 posts at DZone.
- Login or register to post comments
- 329 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)









