<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Otaqui.Com &#187; internet-explorer</title>
	<atom:link href="http://otaqui.com/blog/tag/internet-explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://otaqui.com/blog</link>
	<description>Pete Otaqui's blog about web development and everything else</description>
	<lastBuildDate>Wed, 23 Jun 2010 09:55:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Fix The &#8220;For Attribute Resets Focus on Select Tag&#8221; Bug In Internet Explorer using Prototype</title>
		<link>http://otaqui.com/blog/435/fix-the-for-attribute-resets-focus-on-select-tag-bug-in-internet-explorer-using-prototype/</link>
		<comments>http://otaqui.com/blog/435/fix-the-for-attribute-resets-focus-on-select-tag-bug-in-internet-explorer-using-prototype/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 10:20:36 +0000</pubDate>
		<dc:creator>pete</dc:creator>
				<category><![CDATA[Professional]]></category>
		<category><![CDATA[internet-explorer]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://otaqui.com/blog/?p=435</guid>
		<description><![CDATA[Browser sniffing is bad, or so the logic goes. There are occasions though where it makes perfect sense &#8211; for example where you are fixing a known bug in a specific version of a browser. A good example is the bug in IE 6 that resets the selected index of a Select tag that has [...]]]></description>
			<content:encoded><![CDATA[<p>Browser sniffing is <em>bad</em>, or so the logic goes.</p>
<p>There are occasions though where it makes perfect sense &#8211; for example where you are fixing a known bug in a specific version of a browser.  A good example is the bug in IE 6 that resets the selected index of a Select tag that has a label and the for attribute.  This bug doesn&#8217;t affect IE 7 or 8, or any other browser, but does make for a bad user experience if you are doing the right thing and including labels for your select tags.</p>
<p>Microsoft has <a href="http://support.microsoft.com/kb/314279">published some javascript to fix this</a> and I adapted their code to work with with the <a href="http://prototypejs.org">Prototype Javascript Library</a>.</p>
<p>This fix will look for all select tags on the page (you could adapt it to only look for those with the &#8220;for&#8221; attribute but I have a sneaking suspicion that if anything that would in fact be a bit slower) and observe the onfocusin and onfocus events as suggested in the knowledge base article.</p>
<pre class="brush: javascript">
// Select with &#039;for&#039; attribute fix for IE
Event.observe(window,&#039;load&#039;,function() {
	if ( !Prototype.Browser.IE || !(parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf(&quot;MSIE&quot;)+5))==6) ) return;
	$$(&#039;select&#039;).each(function(eSelect) {
		eSelect.observe(&#039;focusin&#039;,function(e) {
			try {
				var eSrc = window.event.srcElement;
				if ( eSrc ) eSrc.tmpIndex = eSrc.selectedIndex;
			} catch(e) {}
		});
		eSelect.observe(&#039;focus&#039;,function(e) {
			try {
				var eSrc = window.event.srcElement;
				if ( eSrc ) eSrc.selectedIndex = eSrc.tmpIndex;
			} catch(e) {}
		})
	});
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://otaqui.com/blog/435/fix-the-for-attribute-resets-focus-on-select-tag-bug-in-internet-explorer-using-prototype/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
