<?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/"
	 xmlns:slash="http://purl.org/rss/1.0/modules/slash/" 
>

<channel>
	<title>Daniel Bergey &#187; jquery</title>
	<atom:link href="http://danielbergey.com/motion/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://danielbergey.com/motion</link>
	<description>Commotion</description>
	<lastBuildDate>Mon, 02 Nov 2009 02:45:59 +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>IE Version Reporting in jQuery</title>
		<link>http://danielbergey.com/motion/2008/09/ie-version-reporting-in-jquery/</link>
		<comments>http://danielbergey.com/motion/2008/09/ie-version-reporting-in-jquery/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 04:40:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://www.danielbergey.com/weblog/?p=524</guid>
		<description><![CDATA[Lately in the course of programming events, it came to my attention that under some circumstances IE 7 identifies itself as both IE 6 and IE 7 in the same userAgent string. Worse, I discovered to my horror that jQuery reports it as IE 6 if the IE 6 declaration happens to be ordered last. [...]]]></description>
			<content:encoded><![CDATA[<p>Lately in the course of programming events, it came to my attention that under some circumstances IE 7 identifies itself as both IE 6 and IE 7 in the same userAgent string. Worse, I discovered to my horror that jQuery reports it as IE 6 if the IE 6 declaration happens to be ordered last. This would never do.</p>

<p>The following code snippet will refine jQuery&#8217;s browser detection (tested in 1.2.6, <a href="http://dev.jquery.com/ticket/3402">patch submitted for 1.3</a>), and makes sure that if two or more IE version declarations are present in the userAgent string, jQuery reports the highest of them.</p>

<p><style>
code[language=javascript] {
    font: 10px &#8220;bitstream vera sans mono&#8221;, monaco, courier;
    line-height: 140%;
    white-space: pre;
    padding: 0&#160;20px 12px 20px;
    background: #eee;
    color: #666;
    display: block;
    border: 3px solid #ccc;
    border-width: 2px 0;
    overflow: auto;
}
</style>
<code language="javascript">
// Ensure that we report the highest IE version present in the userAgent string
if ( jQuery.browser.msie )
    jQuery.browser.version = (userAgent.match( /ie ([\d.]+)/ig ) || [])
        .sort().pop().replace( /[^\d.]/g, '' );
</code></p>

<p>To use it, you can either paste it into your jquery.js just after the browser detection stuff (harder), or include it as a script plugin after your jQuery script tag (easier).</p>

<div class="warning"><b>Disclaimer:</b> I&#8217;ve done some rudimentary testing, but you&#8217;re responsible for testing it in your own web project.</div>

<p>This all comes about for several reasons: the True IE 6 obviously won&#8217;t be mentioning IE 7 because it didn&#8217;t exist at release time, but the True IE 7 might want to pretend it was IE 6 for compatibility with older pages. There&#8217;s also apparently <a href="http://jamazon.co.uk/web/2008/07/23/an-ie7-bug-that-returns-msie-60-user-agent-string/">a situation</a> wherein an extra-long Windows registry entry will overwhelm IE 7 to the point where it falls back to reporting itself as IE 6.</p>

<p>If similar situations arise after IE 8 (final) is released, this code should take care of those, too. I say &#8220;should,&#8221; because I obviously don&#8217;t know what IE&#8217;s going to do in the future. (Sometimes I don&#8217;t even know what IE&#8217;s doing <em>right now</em>.)</p>
<div class="smartshare" style="display: none;"></div>]]></content:encoded>
			<wfw:commentRss>http://danielbergey.com/motion/2008/09/ie-version-reporting-in-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	<slash:comments>3</slash:comments>
	</item>
	</channel>
</rss>
