09 January 2007

Image inputs in MSIE7

I saw a post in the last couple of days saying that <* input type="image"> doesn't work in MSIE7. I've recently been working on a project which happens to have one of these elements. I tested it in MSIE7 today, and sure enough, it doesn't work. But it's broken in a very subtle way.

The element in my project looks like this...

<* input type="image" name="ick" value="gakkk" src="button.jpg" />

...and the interface to which this form POSTs looks for the ick field. Looks to me like MSIE7 just doesn't send any name/value data in one of these elements when the form is submitted. All the other form fields make it into the POST data, just not the ick/gakkk pair.

Either of the following seemed to make it work as expected:
  1. turning the input element into a normal type="submit"
  2. moving the ick/gakkk name/value pair into a hidden input element in the form
I don't know if this is a bug in MSIE7 or if it is intentional behavior. The W3C HTML4.01 recommendation for the input element lists the name and value attributes, with no obvious (to me) exception for image-type input elements.

*sigh* Just one more stupid thing I have to remember when designing Web applications.

No comments: