<feed xmlns="http://www.w3.org/2005/Atom" xmlns:foaf="http://xmlns.com/foaf/0.1/"><title>norman.walsh.name: Comments on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE"/><id>http://norman.walsh.name/2009/03/24/jQueryIE/comments.atom</id><updated>2012-02-13T09:58:11.814886Z</updated><entry><title>Comment 1 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0001"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0001</id><published>2009-03-24T22:25:40Z</published><updated>2009-03-24T22:25:40Z</updated><author><name>Bryan</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>http://webbugtrack.blogspot.com/2007/11/bug-193-onchange-does-not-fire-properly.html
</p>
    <p>
"The onchange event can be attached (inline or as an event handler) to any form element. It fires whenever the value of the form field changes. Unfortunately, the behavior is a bit strange in IE, in that for a checkbox, or a radio button field, the event doesn't fire when it is supposed to (right when you click the option you want to choose), but instead it only fires, when you click elsewhere on the page/form, or if you explicitly call blur(); on the field."</p>
  </div></content></entry><entry><title>Comment 2 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0002"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0002</id><published>2009-03-25T06:21:31Z</published><updated>2009-03-25T06:21:31Z</updated><author><name>Shawn Medero</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>I don't know the historical reasons but in IE5-&gt;IE8 you're best bet with <code>&lt;input&gt;</code> &amp; <code>@type=radio</code> or <code>@type=checkbox</code> is to use the click event. I believe it is also possible to use change, if you fire the blur event yourself. 
</p>
    <p>
If anyone knows the historical reasons for this, I'd love to know... I'm on vacation or I do the list archaeology myself.</p>
  </div></content></entry><entry><title>Comment 3 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0003"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0003</id><published>2009-03-25T10:43:00Z</published><updated>2009-03-25T10:43:00Z</updated><author><name>Rob Koberg</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>just use the click event - same thing</p>
  </div></content></entry><entry><title>Comment 4 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0004"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0004</id><published>2009-03-25T11:59:17Z</published><updated>2009-03-25T11:59:17Z</updated><author><name>Norman Walsh</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Click <em>is not</em> the same thing. Click fires even if you click on <em>the same</em> radio button. So either I have to accept that that is uncommon enough not to care or I have to track the current state of all the buttons separately.
</p>
    <p>
Not that it looks like I have much choice.
</p>
    <p>
[expletives deleted --ed]</p>
  </div></content></entry><entry><title>Comment 5 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0005"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0005</id><published>2009-03-25T14:46:59Z</published><updated>2009-03-25T14:46:59Z</updated><author><name>Jacek</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Can you do onclick=this.blur()? (syntax uncertain) This could lead to the right onchange events, if I understand the other comments right.</p>
  </div></content></entry><entry><title>Comment 6 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0006"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0006</id><published>2009-03-27T10:47:07Z</published><updated>2009-03-27T10:47:07Z</updated><author><name>Rob Koberg</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>"Click is not the same thing. Click fires even if you click on the same radio button."
</p>
    <p>
Which is what you want. A click <em>should</em> change/toggle a radio button or checkbox.</p>
  </div></content></entry><entry><title>Comment 7 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0007"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0007</id><published>2009-03-27T11:38:49Z</published><updated>2009-03-27T11:38:49Z</updated><author><name>Norman Walsh</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>No, it isn't what I want. Luckily, it turns out in this application that it's close enough.
</p>
    <p>
Consider three mutually exclusive options A, B, and C represented by a group of radio buttons. Initially A is selected.
</p>
    <p>
I click on B: the radio button changes and both the onClick and onChange events fire.
</p>
    <p>
I click on B again: the radio button doesn't change and the onClick event fires, but the onChange event does not.
</p>
    <p>
Since it's only the change of a radio button that I care about, I'd prefer to hang my code off the onChange event.
</p>
    <p>
Except that in yet another bit of IE buggyness, the onChange event doesn't fire until the focus leaves the button group.
</p>
    <p>
%$#@?!</p>
  </div></content></entry><entry><title>Comment 8 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0008"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0008</id><published>2009-06-18T16:39:15Z</published><updated>2009-06-18T16:39:15Z</updated><author><name>Mark Sheppard</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Just came across this myself in IE8.  You'd have thought Microsoft would have fixed this bug by now......</p>
  </div></content></entry><entry><title>Comment 9 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0009"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0009</id><published>2009-07-09T11:23:07Z</published><updated>2009-07-09T11:23:07Z</updated><author><name>Five Minute Argument</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>To all those saying "use click, it's the same":
</p>
    <p>
a) It's obviously not the same; it wouldn't exist if it were
</p>
    <p>
b) Using click breaks all UI methods that are NOT moving a mouse pointer over the element and clicking the button. Most significantly, this breaks keyboard accessibility. 'change' has the wonderful property that, in half-decent browsers, it does exactly what it says: fires if the value changes, however that change might occur (e.g. I hope - although haven't tested - that it would also fire if the value was programatically changed)
</p>
    <p>
I thought jQuery was supposed to solve all these horrible cross-browser problems! Do you know if anyone's working on fixing this? It seems as if whatever fix can be applied by all of us (however insufficient that fix might be), can also be applied in the jQuery library, saving us the bother.
</p>
    <p>
Cheers,
</p>
    <p>
- Bobby</p>
  </div></content></entry><entry><title>Comment 10 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0010"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0010</id><published>2009-07-18T22:59:32Z</published><updated>2009-07-18T22:59:32Z</updated><author><name>Chris Loosley</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Click could be an alternative in some cases but here's a case where click does not apply. I am trying to use Ben Nadel's example of listening for changes in the browser location object -- see <a rel="nofollow" href="http://www.bennadel.com/blog/1520-Binding-Events-To-Non-DOM-Objects-With-jQuery.htm">Binding Events To Non-DOM Objects With jQuery</a>, and using this to adjust html element classes.
</p>
    <p>
This works nicely in Firefox, Safari, and Chrome, but in IE it only works in the "forward" direction, when changes to the window location (specifically, the hash value) are the result of clicks. When I use the browser's back button, the hash values change, but IE does not execute the function that I have bound to that change.
</p>
    <p>
Now I have to waste another day figuring out a workaround. I hate IE.</p>
  </div></content></entry><entry><title>Comment 11 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0011"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0011</id><published>2009-09-16T09:06:49Z</published><updated>2009-09-16T09:06:49Z</updated><author><name>Alexander M. Turek</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">If you click on a radio button, IE seems to wait with firing the change event until you leave the button, which is consistent with the behavior on other input fields (like text), but kinda unintuitive.

The following piece of code fixes this behavior for me:

<pre>
$(function () {
    if ($.browser.msie) {
        $('input:radio').click(function () {
            this.blur();
            this.focus();
        });
    }
});
</pre></div></content></entry><entry><title>Comment 12 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0012"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0012</id><published>2009-09-24T08:30:45Z</published><updated>2009-09-24T08:30:45Z</updated><author><name>marco</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Alexander, you saved me hours of endless tweaking with IE! That click handler works just fine.
</p>
    <p>
Thanks.</p>
  </div></content></entry><entry><title>Comment 13 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0013"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0013</id><published>2009-11-06T16:28:55Z</published><updated>2009-11-06T16:28:55Z</updated><author><name>Hectic Jeff</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>@Alexander M. Turek Thank you so much for this, as marco has mentioned above, this works perfectly and has saved me *hours* of trouble! 
</p>
    <p>
I'm surprised that jQuery doesn't have this feature built into the core, this is certainly one of those cross browser issues that should be addressed by the library.</p>
  </div></content></entry><entry><title>Comment 14 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0014"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0014</id><published>2009-11-09T02:07:56Z</published><updated>2009-11-09T02:07:56Z</updated><author><name>Eric Howe</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Another pat on the back for Alexander M. Turek, that kludge did the trick for me.
</p>
    <p>
And a kick in the teeth to the IE team at Microsoft for making us suffer so much.
</p>
    <p>
I also noticed that IE8 (and probably seven) doesn't seem to understand label tags whose content is an image so I'm off to write a click handler for my image labels...</p>
  </div></content></entry><entry><title>Comment 15 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0015"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0015</id><published>2009-12-01T22:58:12Z</published><updated>2009-12-01T22:58:12Z</updated><author><name>Dennis Monsewicz</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Thanks Alexander! This saved my tail on a huge project :D</p>
  </div></content></entry><entry><title>Comment 16 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0016"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0016</id><published>2009-12-02T18:02:35Z</published><updated>2009-12-02T18:02:35Z</updated><author><name>Vince</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Alexander, perfect fix! This seems to be working perfectly in all the IE browsers. Very clever.</p>
  </div></content></entry><entry><title>Comment 17 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0017"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0017</id><published>2009-12-14T21:19:04Z</published><updated>2009-12-14T21:19:04Z</updated><author><name>Jermaine Maree</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Wish I would have found this a few hours ago ;-) Better late than never I guess. Now I can move on to more important things. Alexander's code is perfect!</p>
  </div></content></entry><entry><title>Comment 18 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0018"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0018</id><published>2010-02-16T13:25:07Z</published><updated>2010-02-16T13:25:07Z</updated><author><name>Izik</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>WOW!!! Well done!!!</p>
  </div></content></entry><entry><title>Comment 19 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0019"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0019</id><published>2010-02-26T14:15:04Z</published><updated>2010-02-26T14:15:04Z</updated><author><name>Martijn Bak</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Thanks!
</p>
    <p>
Works also well for checkboxes...
</p>
    <p>
Unfortunately, in my case the next checkbox happened to be hidden, so I got an error:
</p>
    <p>
<i>Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.</i>
</p>
    <p>
Agrgrh!
</p>
    <p>
IE Sucks. Why do we continue trying to waist so much time, money and effort getting things sort of working in this piece of crap. This only causes the world to keep using IE. So that we have to go on supporting IE, so that the world keeps using it, so that ...
</p>
    <p>
Martijn</p>
  </div></content></entry><entry><title>Comment 20 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0020"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0020</id><published>2010-03-04T09:16:36Z</published><updated>2010-03-04T09:16:36Z</updated><author><name>Milhouse</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>Thanks, saved my day.</p>
  </div></content></entry><entry><title>Comment 21 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0021"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0021</id><published>2010-04-20T17:58:58Z</published><updated>2010-04-20T17:58:58Z</updated><author><name>ThanksAlex</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>wow, saved me some time there, could not figure out why IE8 would not focus on a post-page load created DOM element (while safari and FF do just fine).
</p>
    <p>
We have a have a multiple choice survey [single page for admins] with @70 multi-checkbox response questions.
</p>
    <p>
Workaround in my case was to focus on the first unchecked checkbox in target group, and then blur() on that element.  At this point IE now responds to further event.  We then focus on the post-page load created DOM element (positioned above the question text) and remove() it.
</p>
    <p>
No more need to pop an alert in IE in order to get the focus() working.
</p>
    <p>
I concur with everyone here re: the utter piece of trash-edness that is IE...</p>
  </div></content></entry><entry><title>Comment 22 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0022"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0022</id><published>2010-04-27T20:05:58Z</published><updated>2010-04-27T20:05:58Z</updated><author><name>Erik</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>http://msdn.microsoft.com/en-us/library/ms536912%28VS.85%29.aspx
</p>
    <p>
They seem to think it's not a bug but a feature.</p>
  </div></content></entry><entry><title>Comment 23 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0023"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0023</id><published>2010-06-01T21:04:12Z</published><updated>2010-06-01T21:04:12Z</updated><author><name>Hank</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">
    <p>I almost thought Alexander's jQuery solution didn't work...but it's because I was still using the "onclick" event for the radio button.  Make sure to use "onchange" in the radio button.
</p>
    <p>
BTW, I understand that Microsoft was trying to be consistent with the other elements.  However, this goes to show why I disagree with UI experts who have concrete rules like "strict consistency" and "shortest mouse distance".  My #1 rule is that rules should be broken if they don't feel right...and in this case, I can't think of a single use-case for Microsoft's implementation.  In every use case I've run into, Microsoft's implementation was just wrong.
</p>
    <p>
That being said, I think Microsoft actually chose a better Box Model.  The standard box model makes it impossible to use percentage widths totaling 100% while using fixed pixel paddings (your total width will be 100% plus all of the paddings).  Of course CSS3 solves this in two ways: letting us choose the box model, or using expressions.  I guess IE is like a broken clock...it's still right twice a day.</p>
  </div></content></entry><entry><title>Comment 24 on /2009/03/24/jQueryIE</title><link rel="alternate" type="text/html" href="http://norman.walsh.name/2009/03/24/jQueryIE#comment0024"/><id>http://norman.walsh.name/2010/09/25/oauth#comment0024</id><published>2010-11-23T12:23:02Z</published><updated>2010-11-23T12:23:02Z</updated><author><name>Chris</name><foaf:mbox_sha1sum>da39a3ee5e6b4b0d3255bfef95601890afd80709</foaf:mbox_sha1sum></author><content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>I had the same issue running jQuery 1.3.2, but was fixed when I
upgraded to 1.4.4. The W3C specification does actually say that
onchange events should only be fired when the element loses focus,
so unfortunately in this instance MS aren't in the wrong.</p></div></content></entry></feed>

