Well I thought I’d kick off the New Year by documenting an annoying and frustrating “undocumented feature” of IE and Opera.
This one is pretty simple and I guess it’s fairly obvious when you think about it but it’s not consistent with other platforms or this web developer’s expectations of browser behaviour.
Internet Explorer 7 and Opera 9, as far as I can tell do not send the form element details correctly when the form is submitted. Instead of posting the input element name and value, they post the input name with the x and y co-ordinates of the mouse pointer at the time of clicking. This information is also sent by Firefox and other browsers but they do send it together with the actual element name and value as well.
Important information e.g. the Value of the button could be missed by these browsers
The real gotcha is if you are processing a form and performing alternate actions when a button is clicked on (eg you may have an ‘Upload Image’ button and a ‘Finish’ button). Testing that the button has been clicked by looking for a POST or GET value of the button name will not give you the correct result when the button was clicked in IE.
To replicate this behaviour:
Create a form and add a graphical submit button to it, with a name of “submit”
<form action="/Search/" method="get"> <input name="search" type="text" /> <input id="submit" alt="search" name="submit" />
src="images/btn_search.gif" type="image" value="submit" />
you would expect that as it’s an input source that the submit value will be transmitted as part of the form.
Here is the output displayed when the form is submitted to this simple script
this is what you see when you View Source in Firefox and Safari
see the final value – submit (the button) has a value of “submit”
now lets View Source in Internet Explorer 7 and Opera 9
nada – zip, zilch, nothing
As far as I know, when you create an input element in a form that element has to pass its value by name, eg. last_name=layfield otherwise it is not behaving correctly.