Note that there are some explanatory texts on larger screens.

plurals
  1. POonchange on radiobutton not working correctly in IE8
    primarykey
    data
    text
    <p>I'm forced to work with IE8 (8.0.7601.17514) and I have this simple page:</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" &gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="."&gt; &lt;input type="radio" name="rad" value="1" onchange="alert(1);"/&gt; &lt;input type="radio" name="rad" value="0" onchange="alert(0);" checked="checked"/&gt; &lt;/form&gt; &lt;a href="http://google.com"&gt;some dummy link&lt;/a&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>What I expect is that as the second radio button is selected, clicking on the first one will immediately raise an Alert. This works fine in FF.</p> <p>What actually happens is that when I click the first radio, nothing happens. Then, when the element is blurred (eg. I click somewhere else, the other radio, some link in the page etc), THEN the alert is raised.</p> <p>Is there a workaround to this?</p> <p><strong>EDIT:</strong> </p> <p>apparently this behavior is exactly according to <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-eventgroupings-htmlevents" rel="noreferrer">W3C spec</a></p> <blockquote> <p><strong>change</strong></p> <p>The change event occurs when a control loses the input focus and its value has been modified since gaining focus. This event is valid for INPUT, SELECT, and TEXTAREA. element.</p> </blockquote> <p>(thanks to @mu-is-too-short).</p> <p>The workaround to this is to add a onclick blur+focus:</p> <pre><code>function radioClick() { this.blur(); this.focus(); } &lt;input type="radio" name="rad" value="1" onclick="radioClick" onchange="alert(1);"/&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload