<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Why browser detection with JavaScript is a bad habit?</title>
	<atom:link href="http://www.maratz.com/blog/archives/2006/02/02/why-browser-detection-is-a-bad-habit/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maratz.com/blog/archives/2006/02/02/why-browser-detection-is-a-bad-habit/</link>
	<description>Hypertext rulez™</description>
	<pubDate>Fri, 21 Nov 2008 13:58:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Brad Wright</title>
		<link>http://www.maratz.com/blog/archives/2006/02/02/why-browser-detection-is-a-bad-habit/#comment-1864</link>
		<dc:creator>Brad Wright</dc:creator>
		<pubDate>Fri, 03 Mar 2006 10:54:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2006/02/02/why-browser-detection-is-a-bad-habit/#comment-1864</guid>
		<description>A little off-topic, but we use this method at work to create an "Ajax" object:

&lt;code&gt;function AJAX() {
    var o = false;
    /*@cc_on @*/
    /*@if (@_jscript_version &gt;= 5)
        try {
            o = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                o = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                o = false;
            }
        }
        @end @*/
        if (!o &#038;&#038; typeof XMLHttpRequest!='undefined') {
            o = new XMLHttpRequest();
        }	
        return o;
}&lt;/code&gt;

Sorry for the rough formatting.

Anyway, explanation is that it uses conditional compilation (all that &lt;code&gt;@cc_on&lt;/code&gt; stuff) to do some serious browser/object forking. Hope that helps. If the function returns &lt;code&gt;false&lt;/code&gt;, then the browser doesn't support Ajax. Otherwise the return value is an Ajax object.</description>
		<content:encoded><![CDATA[<p>A little off-topic, but we use this method at work to create an &#8220;Ajax&#8221; object:</p>
<p><code>function AJAX() {<br />
    var o = false;<br />
    /*@cc_on @*/<br />
    /*@if (@_jscript_version >= 5)<br />
        try {<br />
            o = new ActiveXObject("Msxml2.XMLHTTP");<br />
        } catch (e) {<br />
            try {<br />
                o = new ActiveXObject("Microsoft.XMLHTTP");<br />
            } catch (E) {<br />
                o = false;<br />
            }<br />
        }<br />
        @end @*/<br />
        if (!o &#038;&#038; typeof XMLHttpRequest!='undefined') {<br />
            o = new XMLHttpRequest();<br />
        }<br />
        return o;<br />
}</code></p>
<p>Sorry for the rough formatting.</p>
<p>Anyway, explanation is that it uses conditional compilation (all that <code>@cc_on</code> stuff) to do some serious browser/object forking. Hope that helps. If the function returns <code>false</code>, then the browser doesn&#8217;t support Ajax. Otherwise the return value is an Ajax object.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Perkins</title>
		<link>http://www.maratz.com/blog/archives/2006/02/02/why-browser-detection-is-a-bad-habit/#comment-1796</link>
		<dc:creator>Justin Perkins</dc:creator>
		<pubDate>Thu, 02 Feb 2006 14:36:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.maratz.com/blog/archives/2006/02/02/why-browser-detection-is-a-bad-habit/#comment-1796</guid>
		<description>Perfect.

There's a good chance that people who write browser sniffing Javascript have no idea what that code above is though (object literal notation). The first time I saw it, it looked a little cryptic and was taken aback.</description>
		<content:encoded><![CDATA[<p>Perfect.</p>
<p>There&#8217;s a good chance that people who write browser sniffing Javascript have no idea what that code above is though (object literal notation). The first time I saw it, it looked a little cryptic and was taken aback.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
