IE8, the enter key, and forms

Today, working on my work mail server’s admin interface, I discovered that IE8 treats submitted forms differently from all other browsers on the market. Including previous versions of Internet Explorer, at that.

The de facto standard is, if you have multiple forms that post to a single script, and you want that script to check to see what form was submitted, you’d check to see if the name of the submit button was set as a variable in the POST variables. To wit:

<form action="index.php" method="post">
    Search: <input name="searchterms">
    <input type="submit" name="search" value="Go">

This would post whatever you typed into the box as the value for “searchterms”, and would set “Go” as the value of the variable “search”. You could then check if $_POST[‘search’] was set, then do your search.

IE8, however, does something interesting. It is the only browser I’ve seen to do this, and I’ve tested older versions of IE, Chrome, Chromium, Opera, Firefox, and Safari against this bug. If you search for something then hit Enter instead of clicking the Go button, it will not post anything for “search” at all. The variable will simply not get set.

The only workaround I could find, short of hacking in a Javascript check for Enter keys, was to do as follows:

<form action="index.php" method="post">
    Search: <input name="searchterms">
    <input type="hidden" name="search" value="true">
    <input type="submit" value="Go">

This is not a terrible or onerous workaround, but why in the hell am I developing against a browser that, despite Microsoft’s reams and reams of money and scores and scores of programmers, has idiosyncrasies that should be easy to spot and patch and yet go unpatched even while IE9 is in beta?

Well, it’s because IE is the standard browser in the company. Only myself and a handful of oddballs use Firefox, though the Mac users tend toward Safari.

To make matters only slightly more annoying, none of my nice shiny rounded CSS renders properly in IE8. I’ve added three versions of the same CSS for maximum cross-browser compatibility, but IE is the only browser on the market that refuses to even look cross-eyed at the code. And it makes a mess of placement, too. These are simple Divs with width and height set, and inline display. Look:

Login -- Firefox 3.6 on Ubuntu
Login -- Internet Explorer 8 on Windows XP
Tab bar -- Firefox 3.6 on Ubuntu
Tab bar -- Internet Explorer 8 on Windows XP

I’ve pretty much decided I can’t be bothered with making this user interface look the same across all browsers. There would be too much unique CSS, and/or the necessity for images (which I’ve thus far completely avoided — clean, simple, all text, and still looks relatively attractive). I get the feeling when IE9 comes out, if (heavens forefend!) they decide to start supporting CSS properly, someone will congratulate me on how pretty my new admin interface upgrades look. And I’ll be forced to punch that someone.

IE8, the enter key, and forms

One thought on “IE8, the enter key, and forms

Comments are closed.