Jump to content

Differing Form Behavior


jesh

Recommended Posts

I've noticed something for the first time and was hoping someone here would be able to either provide me with some answers or point me somewhere where I could learn more about this strange behavior.Look at this simple (test) page:

<html><body><form><table>	<tr>	  <td>Some text in a table</td>	</tr></table><input type="submit" /></form></body></html>

If you view that in Firefox or Opera and you click on "Some text in a table", nothing, as would be expected, happens. On the other hand, if you view that in IE6 and click on "Some text in a table", the submit button gets focus.Anybody have any ideas why this happens? Know any solutions to prevent this from happening?

Link to comment
Share on other sites

That's a "feature" of IE, if you click anything inside a form (regardless of whether or not it is actually a form element) IE gives the form (and the submit button) focus. About the only thing you can do is put an onfocus handler on the button to remove focus, but that would mess up people trying to use keyboard navigation.

Link to comment
Share on other sites

Ah, another "feature". Thanks for the response. It looks like this is only happening when there is a table inside the form. I tried adding click events to the tds and the table to return false. I also tried blurring the button when the tds or the table was clicked, but this appears to be happening at a deeper level in the browser. And the Google search for "IE form table button focus" isn't very helpful. :)Guess it's time to rebuild this old code to get rid of the tables.

<html><head><style>td { background-color: red; }div { background-color: yellow; }form { background-color: green; }</style></head><body><form><table>	<tr>	  <td>Some text in a table</td>	</tr></table><div>Some text in a div</div><input type="submit" /></form></body></html>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...