<?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>thetransient &#187; example</title>
	<atom:link href="http://www.thetransient.com/tag/example/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thetransient.com</link>
	<description>One designer's web design blog</description>
	<lastBuildDate>Wed, 12 May 2010 17:21:11 +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>IE6 sniffer using conditional comments</title>
		<link>http://www.thetransient.com/ie6-sniffer-using-conditional-comments/197/</link>
		<comments>http://www.thetransient.com/ie6-sniffer-using-conditional-comments/197/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 05:30:40 +0000</pubDate>
		<dc:creator>Erik Phipps</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[example]]></category>

		<guid isPermaLink="false">http://www.thetransient.com/?p=197</guid>
		<description><![CDATA[I needed a fail-proof Internet Explorer 6 JavaScript sniffer and it seemed like everything I Googled warned of possible scenarios where it could possibly not work. Then It struck me that since I only needed to detect one version of Internet Explorer I could make a very simple script using Internet Explorer&#8217;s conditional comments. I [...]]]></description>
			<content:encoded><![CDATA[<p>I needed a fail-proof Internet Explorer 6 JavaScript sniffer and it seemed like everything I Googled warned of possible scenarios where it could possibly not work. Then It struck me that since I only needed to detect one version of Internet Explorer I could make a very simple script using Internet Explorer&#8217;s conditional comments.</p>
<p>I know what you are thinking, that JavaScript sniffers are outdated and go against all that is web standards. I agree. However, as IE6 fades into the past, isn&#8217;t it time we started ignoring instead of bending over backwards for its lack of standards support? This is where a JavaScript browser sniffer comes in!</p>
<p>Others have probably used this technique and expanded it to other versions of Internet Explorer as well. For this post, I am just going to discuss the IE6 version since it is very simple to expand it to all other versions of IE.</p>
<p>Drop this javascript snippet in a script tag in the head of your document:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> browserSniffer <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>isIE6 <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then, inside an <a href="http://www.quirksmode.org/css/condcom.html">IE conditional comment</a> targeted at IE6, change the value of <strong>isIE6</strong> to &#8220;true&#8221;. Like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserSniffer <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>isIE6 <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>What you end up with is a non-global variable that is always equal to <strong>false </strong>unless the browser is IE6, then it is <strong>true</strong>. You can then easily dis-invite IE6 to the web standards party!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>browserSniffer.<span style="color: #660066;">isIE6</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// fix some bug in IE6</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// Do something sweet in other browsers</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="/wp-content/examples/standalone-examples/ie6-conditional-comment-javascript-browser-sniffer.htm">Standalone example &#8211; IE6 conditional comment javascript browser sniffer</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.thetransient.com/ie6-sniffer-using-conditional-comments/197/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
