<?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; JavaScript</title>
	<atom:link href="http://www.thetransient.com/tag/javascript/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>
		<item>
		<title>Unclutter your website with simple jQuery javascript show and hide</title>
		<link>http://www.thetransient.com/unclutter-your-website-with-simple-jquery-javascript-show-and-hide/110/</link>
		<comments>http://www.thetransient.com/unclutter-your-website-with-simple-jquery-javascript-show-and-hide/110/#comments</comments>
		<pubDate>Sat, 06 Sep 2008 05:39:49 +0000</pubDate>
		<dc:creator>Erik Phipps</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[UI]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[user interface design]]></category>

		<guid isPermaLink="false">http://www.thetransient.com/?p=110</guid>
		<description><![CDATA[Here&#8217;s a tip to reduce clutter on a page with lots of repeating links, icons and/or elements. Say you have a list of search results on your website and each result has many action icons and links. It isn&#8217;t necessary to have to links and icons visible at all times. The non-vital content can be [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a tip to reduce clutter on a page with lots of repeating links, icons and/or elements. Say you have a list of search results on your website and each result has many action icons and links. It isn&#8217;t necessary to have to links and icons visible at all times. The non-vital content can be hidden by default and only shown when the user hovers over the search result containing element.</p>
<p>Check out this <a href="/wp-content/examples/jQuery/post_110_unclutterExample.htm">hiding non-vital content example</a>.</p>
<p>The method for the example is very simple and can be accomplished with a small jQuery function and a single class assigned to each element we want to hide. This can of course be done with plain old javascript as well but I&#8217;ll use jQuery because it&#8217;s so darn easy.</p>
<p>Here is the jQuery code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #006600; font-style: italic;">//hide secondary content</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.secondaryContent&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;visibility&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;hidden&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// toggle secondary content items on hover</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#p110_showHideExample li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.secondaryContent&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;visibility&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;visible&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.secondaryContent&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;visibility&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;hidden&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Now all we need to do is add the class &#8220;secondaryContent&#8221; to any element we want to be visible only when the user mouses over the containing element.</p>
<p>For example, here is the remove link html from the upper right corner of the example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;delete secondaryContent&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;#&quot;</span>&gt;</span>X<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.thetransient.com/unclutter-your-website-with-simple-jquery-javascript-show-and-hide/110/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
