Tag Archives: IE

Internet Explorer 7/Opera 9 form button gotcha

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 with graphical input button

Form with graphical input button

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

Output from Firefox

Output from Firefox

output from Safari

output from Safari

see the final value – submit (the button) has a value of “submit”

now lets View Source in Internet Explorer 7 and Opera 9

output from Internet Explorer 7

output from Internet Explorer 7

output from Opera

output from Opera

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.

JQuery 1.2.6 quirk in Internet Explorer 7

I’ve been doing a lot of work lately with JQuery and I love it… I really do, it’s a great piece of code, nay, framework, that strips out all the pain of working with JavaScript and provides a launchpad for great code and interface adventures.

Nonetheless, it’s not without its headaches and recently I lost a few hours to trying to figure out why my JQuery functionality refuses to work on Internet Explorer 7. It’s very frustrating, as everything works perfectly in Safari and Firefox and then as soon as IE comes up the site goes suddenly two-dimensional with none of the interesting UI customisations that JQuery makes so much fun to build.

After a bout of head scratching, coupled with the realisation that JQuery 1.2.3 works fine I started to experiment with the way the script was invoked, fearing that IE had some kind of issue with it.

Sure enough, that was the source of the problem and as soon as I changed my JQuery initialiser to run the “old-fashioned” way, the scripts came magically back to life. So here it is:

If you’re having problems running JQuery in IE, open your html and look for the following lines

and change them to this. Be sure to check the closing part of the script too, as that is different

hopefully the JQuery developers will sort out that problem in time for the next version…