<?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>Code Couch</title>
	<atom:link href="http://www.codecouch.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codecouch.com</link>
	<description>The ramblings of two code monkeys</description>
	<lastBuildDate>Thu, 19 Nov 2009 15:47:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to stop Internet Explorer from caching AJAX requests</title>
		<link>http://www.codecouch.com/2009/01/how-to-stop-internet-explorer-from-caching-ajax-requests/</link>
		<comments>http://www.codecouch.com/2009/01/how-to-stop-internet-explorer-from-caching-ajax-requests/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 13:53:34 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[IE7]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=250</guid>
		<description><![CDATA[There are several ways to solve the problem of browsers caching AJAX requests. You can use a 'cache buster' parameter, or you can set the response headers server-side. This article discusses these two options.]]></description>
			<content:encoded><![CDATA[<p>I recently had to revisit the issue of IE&#8217;s default cache settings causing problems when making AJAX requests. Out-of-the-box, the cache setting is &#8216;Automatically&#8217;, where pages are only fetched from the server if the cached content is from an earlier day, old or from an earlier session.</p>
<p>This can be a nightmare to deal with, as you cannot ask all users of a web site to change their browser settings.</p>
<p>One workaround is to use a &#8216;cache buster&#8217; parameter in your GET request. Something like this:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;"><span class="kw2">var</span> urlToFetch <span class="sy0">=</span> <span class="st0">'whatever.php?randNum='</span> <span class="sy0">+</span> <span class="kw2">new</span> Date<span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getTime</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div></div>

<p>This works very well, but can have drawbacks, depending on your server setup. For example, if your application server sits behind a caching layer, you wouldn&#8217;t want the URL to be different every time for idempotent requests, as the cached version would never get used, and so your application server would get a direct hit every time.</p>
<p>One way around this without using to parameters is to set the &#8216;Cache-Control&#8217; response header to direct the browser how to cache the response.</p>
<p>The &#8216;Cache-Control&#8217; header can have various values, one of which is &#8216;no-cache&#8217;. This tells the browser that it should not cache the response, so the next time the same URL is requested, new content will always be sent (as there is no previous version in the browser&#8217;s cache).</p>
<p>This is how we do it using Groovy:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;">response.<span class="me1">addHeader</span> <span class="st0">&quot;Cache-Control&quot;</span><span class="sy0">,</span> <span class="st0">&quot;max-age=0,no-cache,no-store&quot;</span></pre></div></div></div>

<p>So really, which method you use boils down to this: If you know that the cache buster will have a performance hit on your setup, then don&#8217;t use it, otherwise use whichever method you prefer.</p>
<p>Also, as a developer, I can highly recommend changing your IE cache settings to &#8216;Every visit to the page&#8217;.</p>
<div class="seeThrough h2Pod "><div class="seeThroughTop"><span class="tl"></span><span class="tr"></span><span class="t"></span></div><div class="seeThroughMiddle"><span class="r"></span><span class="l"></span><span class="m"></span><div class="seeThroughContent">
	<h2>Update 10/02/2008</h2>
</div></div><div class="seeThroughBottom"><span class="bl"></span><span class="br"></span><span class="b"></span></div></div>

<p>We&#8217;re finding that with some of our automated testing, IE 7 still caches the odd file now and then. To get around this, we have modified our &#8216;Cache-Control&#8217; header to include two non-standard properties, &#8216;post-check&#8217; and &#8216;pre-check&#8217;, and added an &#8216;Expires&#8217; header as well:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;">response.<span class="me1">addHeader</span> <span class="st0">&quot;Cache-Control&quot;</span><span class="sy0">,</span> <span class="st0">&quot;max-age=0,no-cache,no-store,post-check=0,pre-check=0&quot;</span><span class="sy0">;</span>
response.<span class="me1">addHeader</span> <span class="st0">&quot;Expires&quot;</span><span class="sy0">,</span> <span class="st0">&quot;Mon, 26 Jul 1997 05:00:00 GMT&quot;</span></pre></div></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2009/01/how-to-stop-internet-explorer-from-caching-ajax-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speed up your Javascript</title>
		<link>http://www.codecouch.com/2009/01/speed-up-your-javascript/</link>
		<comments>http://www.codecouch.com/2009/01/speed-up-your-javascript/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 12:31:38 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=248</guid>
		<description><![CDATA[Nicolas Zakas (of Professional JavaScript, Second Edition fame) has a series of articles discussing improving Javascript performance - avoiding browsers complaining about long-running scripts. Some useful suggestions on how to optimise and chunk interactions.]]></description>
			<content:encoded><![CDATA[<p>I came across some very interesting and informative articles on Javascript performance improvement from Nicolas Zakas (the author of the newly released <strong>Professional JavaScript, Second Edition</strong> book):</p>
<ul>
<li><a href="http://www.nczonline.net/blog/2009/01/13/speed-up-your-javascript-part-1/">Speed up your Javascript part 1</a></li>
<li><a href="http://www.nczonline.net/blog/2009/01/20/speed-up-your-javascript-part-2/">Speed up your Javascript part 2</a></li>
</ul>
<p>This is an ongoing series of articles with specific Javascript examples that make sense.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2009/01/speed-up-your-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use CSS pseudo classes to enhance accessibility</title>
		<link>http://www.codecouch.com/2009/01/use-css-pseudo-classes-to-enhance-accessibility/</link>
		<comments>http://www.codecouch.com/2009/01/use-css-pseudo-classes-to-enhance-accessibility/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 14:42:16 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=246</guid>
		<description><![CDATA[It is very simple to add some CSS rules to make your site more accessible. Read on to find out how you can use pseudo classes to provide extra support for keyboard users in all browsers (including Internet Explorer).]]></description>
			<content:encoded><![CDATA[<p>CSS pseudo-classes are probably not something most people are familiar with &#8211; although many developers would make use of them without necessarily being aware of it! When you hover the mouse over a link, many sites will underline the link for you. This is using the <strong>hover</strong> pseudo-class.</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;">a <span class="br0">&#123;</span> text<span class="sy0">-</span>decoration<span class="sy0">:</span>none<span class="sy0">;</span> <span class="br0">&#125;</span>
a<span class="sy0">:</span>hover <span class="br0">&#123;</span> text<span class="sy0">-</span>decoration<span class="sy0">:</span>underline<span class="sy0">;</span> <span class="br0">&#125;</span></pre></div></div></div>

<p>The above example sets all anchors to have no underline text decoration, and the <strong>hover</strong> pseudo-class sets all anchors to have an underline on them. When the user hovers their mouse over a link, an underline will show under the link. When they move their mouse away, the <strong>hover</strong> pseudo-class stops taking effect and the underline is removed.</p>
<p>Pseudo-classes are supported with all modern browsers, but this support is only for the anchor element. Any attempt to use a pseudo-class on any other element will not work in Internet Explorer 6.</p>
<p>There are other pseudo-classes that can be used to provide a more usable experience for those that primarily use a keyboard to navigation through a page.  The first of these is the <strong>focus</strong> pseudo-class (which take affect when the element gains focus &#8211; such as tabbing to the element). This pseudo-class can be used to style elements when they receive focus.</p>
<p>Building on the initial example, the addition of a <strong>focus</strong> pseudo-class will ensure that the same hover effects (in this case some underline text decoration) are applied when the user tabs focus to the anchor.</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;">a <span class="br0">&#123;</span> text<span class="sy0">-</span>decoration<span class="sy0">:</span>none<span class="sy0">;</span> <span class="br0">&#125;</span>
a<span class="sy0">:</span>hover<span class="sy0">,</span> a<span class="sy0">:</span><span class="kw3">focus</span> <span class="br0">&#123;</span> text<span class="sy0">-</span>decoration<span class="sy0">:</span>underline<span class="sy0">;</span> <span class="br0">&#125;</span></pre></div></div></div>

<p>This would be fine, except that Internet Explorer 6 doesn&#8217;t understand the <strong>focus</strong> pseudo-class at all! The solution is to use the <strong>active</strong> pseudo-class to extend the CSS rule.</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;">a <span class="br0">&#123;</span> text<span class="sy0">-</span>decoration<span class="sy0">:</span>none<span class="sy0">;</span> <span class="br0">&#125;</span>
a<span class="sy0">:</span>hover<span class="sy0">,</span> a<span class="sy0">:</span><span class="kw3">focus</span><span class="sy0">,</span> a<span class="sy0">:</span>active <span class="br0">&#123;</span> text<span class="sy0">-</span>decoration<span class="sy0">:</span>underline<span class="sy0">;</span> <span class="br0">&#125;</span></pre></div></div></div>

<p>The order of the<strong> pseudo-class </strong>rules is important (and if you get the order wrong, you may experience some of the CSS rules displaying inconsistently across browsers). As a general rule, always put pseudo-classes in the following order:</p>
<blockquote><p><strong>link, visited, hover, focus, active</strong></p></blockquote>
<p>So, whenever you define a <strong>hover</strong> pseudo-class CSS rule, consider adding in a <strong>focus</strong> and then an <strong>active</strong> pseudo-class at the same time &#8211; it will help users that choose to use the keyboard to navigate your site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2009/01/use-css-pseudo-classes-to-enhance-accessibility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replacement for &#8220;bind&#8221; or &#8220;bindAsEventListener&#8221; in jQuery</title>
		<link>http://www.codecouch.com/2008/12/replacement-for-bind-or-bindaseventlistener-in-jquery/</link>
		<comments>http://www.codecouch.com/2008/12/replacement-for-bind-or-bindaseventlistener-in-jquery/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 20:21:47 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Binding]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=238</guid>
		<description><![CDATA[Do you need to use the equivalent of Prototype's "bind" or "bindAsEventListener" in jQuery, passing through "this" context? Read on for more!]]></description>
			<content:encoded><![CDATA[<p>After working for many years with the Prototype JS framework, I decided it was time to bite the bullet and learn jQuery.</p>
<p>There were 3 reasons, really&#8230; 1: I&#8217;ve just started a new project and don&#8217;t need most of the bloat Prototype comes with; 2: I can now make a judgement call when it comes to choosing a framework; and 3: It&#8217;s another skill on my CV <img src='http://www.codecouch.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> )</p>
<p>I&#8217;ve just spent the weekend reading <a href="http://www.amazon.co.uk/gp/product/1933988355?ie=UTF8&#038;tag=codcou-21&#038;linkCode=as2&#038;camp=1634&#038;creative=6738&#038;creativeASIN=1933988355">jQuery in Action</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=codcou-21&#038;l=as2&#038;o=2&#038;a=1933988355" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> cover-to-cover, and I can highly recommend it for intermediate or advanced developers looking to see what it offers.</p>
<p>The one thing I miss from Prototype however are the &#8220;bind&#8221; and &#8220;bindAsEventListener&#8221; commands which can set the context (&#8221;this&#8221;) of the callback &#8211; in my case, the instance of a class.</p>
<p>After a bit of searching, I found <a href="http://www.cosmocode.de/en/blogs/gohr/20060724110917/">this post by Andreas Gohr</a>. It was coderjoe&#8217;s comment that set the wheels in motion. He showed that you could rewrite this Prototype code:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;">initialize<span class="sy0">:</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
	Event.<span class="me1">observe</span><span class="br0">&#40;</span>someEl<span class="sy0">,</span> <span class="st0">'click'</span><span class="sy0">,</span>
		<span class="kw1">this</span>.<span class="me1">doSomething</span>.<span class="me1">bindAsEventListener</span><span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>
	<span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div></div>

<p>as this jQuery code:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;">init<span class="sy0">:</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
	<span class="kw2">var</span> self <span class="sy0">=</span> <span class="kw1">this</span><span class="sy0">;</span>
	$<span class="br0">&#40;</span>someEl<span class="br0">&#41;</span>.<span class="me1">bind</span><span class="br0">&#40;</span><span class="st0">'click'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>eventData<span class="br0">&#41;</span> <span class="br0">&#123;</span>
		self.<span class="me1">doSomething</span><span class="br0">&#40;</span>eventData<span class="sy0">,</span> self<span class="br0">&#41;</span><span class="sy0">;</span>
	<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div></div>

<p>The bind (and related) method allows you to pass three parameters, however: the event type, some data, and a callback function. If the data parameter is omitted, the callback can be put as the second parameter.</p>
<p>So, we can re-write that last example using the second data parameter, removing the need to set a scoped variable:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;">init<span class="sy0">:</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
	jQuery<span class="br0">&#40;</span>someEl<span class="br0">&#41;</span>.<span class="me1">bind</span><span class="br0">&#40;</span><span class="st0">'click'</span><span class="sy0">,</span> <span class="br0">&#123;</span>thisContext<span class="sy0">:</span><span class="kw1">this</span><span class="br0">&#125;</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span>eventData<span class="br0">&#41;</span> <span class="br0">&#123;</span>
		eventData.<span class="me1">data</span>.<span class="me1">thisContext</span>.<span class="me1">doSomething</span><span class="br0">&#40;</span>eventData<span class="br0">&#41;</span><span class="sy0">;</span>
	<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/12/replacement-for-bind-or-bindaseventlistener-in-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spell checking in Firefox</title>
		<link>http://www.codecouch.com/2008/12/spell-checking-in-firefox/</link>
		<comments>http://www.codecouch.com/2008/12/spell-checking-in-firefox/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 21:07:05 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[spell]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=233</guid>
		<description><![CDATA[Want to know how to spell check an entire web page in Firefox? Or how to add spell-checking to fields that do not have it by default? Read on for more.]]></description>
			<content:encoded><![CDATA[<p>A handy tip I came across the other day was how to spell-check an entire web page using Firefox &#8211; not just textarea elements.</p>
<p>You basically put the page into design mode &#8211; so the content becomes editable. Enter this in the URL bar:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="javascript" style="color: #000000;">javascript<span class="sy0">:</span><span class="kw1">void</span><span class="br0">&#40;</span>document.<span class="me1">designMode</span><span class="sy0">=</span><span class="st0">'on'</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div></div>

<p>You can also add spell checking to fields which do not have it by default (e.g. single-line input elements) by adding a &#8220;spellcheck&#8221; attribute set to &#8220;true&#8221;, e.g.:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="html4strict" style="color: #000000;"><span class="sc2"><span class="kw2">&lt;input</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text&quot;</span> <span class="kw3">size</span><span class="sy0">=</span><span class="st0">&quot;50&quot;</span> spellcheck<span class="sy0">=</span><span class="st0">&quot;true&quot;</span><span class="kw2">&gt;</span></span></pre></div></div></div>

<p>See <a href="https://developer.mozilla.org/en/Controlling_spell_checking_in_HTML_forms">https://developer.mozilla.org/en/Controlling_spell_checking_in_HTML_forms</a> for more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/12/spell-checking-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How do you vertically centre content using CSS?</title>
		<link>http://www.codecouch.com/2008/10/how-do-you-vertically-centre-content-using-css/</link>
		<comments>http://www.codecouch.com/2008/10/how-do-you-vertically-centre-content-using-css/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 13:12:07 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=201</guid>
		<description><![CDATA[Find out how to do vertical centring (vertical alignment) of content using just CSS (and some div elements).]]></description>
			<content:encoded><![CDATA[<p>How do you vertical centre some content using CSS (and some extra div elements)? This is the same simple layout that used to be achieved using a table and valign attribute. This solution doesn&#8217;t require a table at all (but it does require some extra div elements &#8211; as per the markup below).</p>
<p>With the following markup:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="html4strict" style="color: #000000;"><span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;verticalCenteringOuter&quot;</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;moduleA&quot;</span><span class="kw2">&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;verticalCenteringMiddle&quot;</span><span class="kw2">&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;verticalCenteringInner&quot;</span><span class="kw2">&gt;</span></span>
			<span class="sc2"><span class="kw2">&lt;b&gt;</span></span>Some vertical aligned content here<span class="sc2"><span class="kw2">&lt;/b&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span></pre></div></div></div>

<p>Using the following CSS:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
<span class="re0">#moduleA</span> <span class="br0">&#123;</span>
	<span class="kw1">height</span><span class="sy0">:</span> <span class="re3">300px</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.verticalCenteringOuter</span> <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> table<span class="sy0">;</span>
	<span class="kw1">overflow</span><span class="sy0">:</span> <span class="kw2">hidden</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.verticalCenteringMiddle</span> <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">table-cell</span><span class="sy0">;</span>
	<span class="kw1">vertical-align</span><span class="sy0">:</span> <span class="kw2">middle</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
&lt;/style<span class="sy0">&gt;</span>
&nbsp;
&lt;!--<span class="br0">&#91;</span>if IE<span class="br0">&#93;</span><span class="sy0">&gt;</span>
&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
<span class="re1">.verticalCenteringOuter</span> <span class="br0">&#123;</span>
	<span class="kw1">position</span><span class="sy0">:</span> <span class="kw2">relative</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.verticalCenteringMiddle</span> <span class="br0">&#123;</span>
	<span class="kw1">position</span><span class="sy0">:</span> <span class="kw2">absolute</span><span class="sy0">;</span>
	<span class="kw1">top</span><span class="sy0">:</span> <span class="re3"><span class="nu0">50</span>%</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="re1">.verticalCenteringInner</span> <span class="br0">&#123;</span>
	<span class="kw1">position</span><span class="sy0">:</span> <span class="kw2">relative</span><span class="sy0">;</span>
	<span class="kw1">top</span><span class="sy0">:</span> -<span class="re3"><span class="nu0">50</span>%</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
&lt;/style<span class="sy0">&gt;</span>
&lt;!<span class="br0">&#91;</span>endif<span class="br0">&#93;</span>--<span class="sy0">&gt;</span></pre></div></div></div>

<p>Full credit on this to <a href="http://www.jakpsatweb.cz/css/css-vertical-center-solution.html">Yuhů (www.jakpsatweb.cz)</a>. Thanks for the inspiration on this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/10/how-do-you-vertically-centre-content-using-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problems tabbing through checkboxes and radios in MacOSX Safari</title>
		<link>http://www.codecouch.com/2008/10/problems-tabbing-through-checkboxes-and-radios-in-macosx-safari/</link>
		<comments>http://www.codecouch.com/2008/10/problems-tabbing-through-checkboxes-and-radios-in-macosx-safari/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 12:45:34 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[MacOSX]]></category>
		<category><![CDATA[Safari]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=199</guid>
		<description><![CDATA[Many people find it easier to use the tab key to cycle through the various fields of a form in a web page. If you are using a browser in MacOSX, you will find that you cannot use the tab key to access checkboxes or radio buttons... instead you have to use the mouse/trackpad. Read on for a solution.]]></description>
			<content:encoded><![CDATA[<p>Many people find it easier to use the tab key to cycle through the various fields of a form in a web page. This is a well supported and adopted behaviour &#8211; yet if you are using a browser in MacOSX, you will find that you cannot use the tab key to access checkboxes or radio buttons&#8230; instead you have to use the mouse/trackpad.</p>
<p>The solution is rather trivial &#8211; and also very simple to achieve.</p>
<p>Open the System Preferences application and choose Keyboard &#038; Mouse then change the Keyboard Shortcuts option to &#8220;All controls&#8221; (this can also be toggled using Control-Function-F7 if you are so inclined).</p>
<p>You can now use the tab key to cycle through checkboxes (use the spacebar to select a checkbox when you have cycled to it) and radio buttons (you can use up/down or left/right arrow keys to toggle a radio button when the group is in focus).</p>
<p>A similar option is available in Safari (MacOSX as well as Windows) in the Preferences menu option (within the Edit menu). Select the Advanced tab and select &#8220;Press Tab to highlight each item on a webpage&#8221;. When enabled, this option allows you to cycle through all elements that can receive focus using option+tab (this includes standard links on the page as well).</p>
<p>I&#8217;d like to credit this &#8220;discovery&#8221; to Brad Jasper and Dylan Ryan at <a href="http://www.mactips.org/archives/2008/04/30/tab-through-checkboxes-and-radio-buttons-in-safari/"> MacTips: Tips &#038; Tricks</a> &#8211; but the post is no longer available. Thanks for the heads-up guys!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/10/problems-tabbing-through-checkboxes-and-radios-in-macosx-safari/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problems with anchors and alpha transparency filters in IE6</title>
		<link>http://www.codecouch.com/2008/10/problems-with-anchors-and-alpha-transparency-filters-in-ie6/</link>
		<comments>http://www.codecouch.com/2008/10/problems-with-anchors-and-alpha-transparency-filters-in-ie6/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 06:29:40 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=195</guid>
		<description><![CDATA[If you use the Microsoft filter CSS property to allow support for an alpha transparent PNG on an element, any links directly within that element are not clickable (in Internet Explorer 6 only). The problem is explained and a solution put forward that will make your links clickable again.]]></description>
			<content:encoded><![CDATA[<p>You can use alpha transparent PNGs in IE6 as described in <a href="http://www.codecouch.com/2007/05/how-do-i-display-alpha-transparent-pngs-across-all-browsers/">How do I display alpha transparent PNGs across all browsers</a>. There is a problem with implementing this solution &#8211; in Internet Explorer 6 links are no longer clickable when they are contained within an element with an alpha transparency filter applied.</p>
<div class="seeThrough h2Pod "><div class="seeThroughTop"><span class="tl"></span><span class="tr"></span><span class="t"></span></div><div class="seeThroughMiddle"><span class="r"></span><span class="l"></span><span class="m"></span><div class="seeThroughContent">
	<h2>The problem</h2>
</div></div><div class="seeThroughBottom"><span class="bl"></span><span class="br"></span><span class="b"></span></div></div>

<p>Consider the following CSS and HTML code snippets that set up the problem with a link contained within a div that has an alpha transparency filter applied to it:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
<span class="re1">.opaque</span> <span class="br0">&#123;</span> <span class="kw1">background</span><span class="sy0">:</span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="re4">images/alphaTransparent<span class="re1">.png</span></span><span class="br0">&#41;</span> <span class="kw2">transparent</span> <span class="kw2">no-repeat</span> <span class="kw1">left</span> <span class="kw1">top</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&lt;/style<span class="sy0">&gt;</span>
&lt;!--<span class="br0">&#91;</span>if IE <span class="nu0">6</span><span class="br0">&#93;</span><span class="sy0">&gt;</span>
&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
<span class="re1">.opaque</span> <span class="br0">&#123;</span>
	<span class="kw1">background-image</span><span class="sy0">:</span> <span class="kw2">none</span><span class="sy0">;</span>
	filter<span class="sy0">:</span> progid<span class="re2">:DXImageTransform</span><span class="re1">.Microsoft</span><span class="re1">.AlphaImageLoader</span><span class="br0">&#40;</span>enabled=true,sizingMethod=<span class="kw2">crop</span>,src=images/alphaTransparent<span class="re1">.png</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
&lt;/style<span class="sy0">&gt;</span>
&lt;!<span class="br0">&#91;</span>endif<span class="br0">&#93;</span>--<span class="sy0">&gt;</span></pre></div></div></div>


<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="html4strict" style="color: #000000;">...
<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;parent&quot;</span> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;opaque&quot;</span><span class="kw2">&gt;</span></span>
    <span class="sc2"><span class="kw2">&lt;span</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;child&quot;</span><span class="kw2">&gt;</span></span>Lorem <span class="sc2"><span class="kw2">&lt;a</span> <span class="kw3">href</span><span class="sy0">=</span><span class="st0">&quot;http://www.codecouch.com&quot;</span><span class="kw2">&gt;</span></span>ipsum<span class="sc2"><span class="kw2">&lt;/a&gt;</span></span> dolor.<span class="sc2"><span class="kw2">&lt;/span&gt;</span></span>
<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
...</pre></div></div></div>

<p>The parent element has a class <b>opaque</b> applied to it which puts an image on the background of the element. In Internet Explorer 6 only, the background image is removed and the proprietary filter property is used. The link inside the child span is no longer clickable in Internet Explorer 6.</p>
<div class="seeThrough h2Pod "><div class="seeThroughTop"><span class="tl"></span><span class="tr"></span><span class="t"></span></div><div class="seeThroughMiddle"><span class="r"></span><span class="l"></span><span class="m"></span><div class="seeThroughContent">
	<h2>The solution</h2>
</div></div><div class="seeThroughBottom"><span class="bl"></span><span class="br"></span><span class="b"></span></div></div>

<p>Make sure the parent element (the element with the filter applied to it) doesn&#8217;t have the position property set on it, and the child element (the element with the link in it) has to have relative position.</p>
<p>The following addition to the above code will make the link clickable:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">&lt;!--<span class="br0">&#91;</span>if IE <span class="nu0">6</span><span class="br0">&#93;</span><span class="sy0">&gt;</span>
&lt;style type=<span class="st0">&quot;text/css&quot;</span><span class="sy0">&gt;</span>
<span class="re0">#child</span> <span class="br0">&#123;</span> <span class="kw1">position</span><span class="sy0">:</span> <span class="kw2">relative</span><span class="sy0">;</span> <span class="br0">&#125;</span>
&lt;/style<span class="sy0">&gt;</span>
&lt;!<span class="br0">&#91;</span>endif<span class="br0">&#93;</span>--<span class="sy0">&gt;</span></pre></div></div></div>

<p>Since it only has to apply for Internet Explorer 6, the &#8220;fix&#8221; can be enclosed within the <a href="http://www.codecouch.com/2007/04/how-to-target-specific-ie-browsers-using-just-html/">conditional comment</a> that targets just that browser. This doesn&#8217;t require any javascript to work (unlike <a href="http://bjorkoy.com/past/2007/4/8/the_easiest_way_to_png/">other solutions</a> that have been posted) and degrades properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/10/problems-with-anchors-and-alpha-transparency-filters-in-ie6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create rollovers without using Javascript</title>
		<link>http://www.codecouch.com/2008/10/create-rollovers-without-using-javascript/</link>
		<comments>http://www.codecouch.com/2008/10/create-rollovers-without-using-javascript/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 13:11:10 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Front-end]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=174</guid>
		<description><![CDATA[Using just CSS, you can do simple (and more complex) rollovers... no javascript required. This post shows how to apply this technique to your own pages with ease - whether it's a colour change or a more complex image swap.]]></description>
			<content:encoded><![CDATA[<p>You can make use of the <b>:hover</b> pseudo class on the anchor tag to change the anchor&#8217;s style attributes. Typically you see this on sites that underline anchors when you mouse over them (when you hover over them). The CSS code to do this simple underlining can look like this:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">a <span class="br0">&#123;</span> <span class="kw1">text-decoration</span><span class="sy0">:</span> <span class="kw2">none</span><span class="sy0">;</span> <span class="br0">&#125;</span>
a<span class="re2">:hover</span> <span class="br0">&#123;</span> <span class="kw1">text-decoration</span><span class="sy0">:</span> <span class="kw2">underline</span><span class="sy0">;</span> <span class="br0">&#125;</span></pre></div></div></div>

<p>We could extend this to change the background and forground colour of the link to make it appear a little more &#8220;box-like&#8221; using something like this CSS code:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">a <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">block</span><span class="sy0">;</span>
	<span class="kw1">padding</span><span class="sy0">:</span> <span class="re3">5px</span> <span class="re3">10px</span><span class="sy0">;</span>
	<span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#FFFFFF</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
a<span class="re2">:hover</span> <span class="br0">&#123;</span>
	<span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#CCCCCC</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div></div>

<p>If you wanted to have a background image on the anchor, then you could change the background-image when you hovered over the anchor. The CSS code might look like this:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">a <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">block</span><span class="sy0">;</span>
	<span class="kw1">padding</span><span class="sy0">:</span> <span class="re3">5px</span> <span class="re3">10px</span><span class="sy0">;</span>
	<span class="kw1">background</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="re4">img/anchor_off<span class="re1">.gif</span></span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span> <span class="kw1">left</span> <span class="kw1">top</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#FFFFFF</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
a<span class="re2">:hover</span> <span class="br0">&#123;</span>
	<span class="kw1">background</span><span class="sy0">:</span> <span class="re0">#CCCCCC</span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="re4">img/anchor_hovered<span class="re1">.gif</span></span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span> <span class="kw1">left</span> <span class="kw1">top</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div></div>

<p>This technique does suffer from a flaw, however. You will invariably see a flickering as you roll over the anchor for the first time due to the browser having to request the second image (assuming the file isn&#8217;t already in the browser cache).</p>
<p>This problem can be fixed by using the same image for both the normal and hover state of the anchor &#8211; just reposition the background image on hover. This is presented very well over at <a href="http://www.alistapart.com/articles/sprites/">A List Apart</a> where Dave Shea introduces the concept of CSS Sprites. The image below (195px wide, 30px high in size) shows how you might set this up:</p>
<p><img src="http://www.codecouch.com/wp-content/uploads/2008/10/cssbuttonbackground.gif" alt="" title="Anchor background sprites" width="195" height="30" /></p>
<p>The image above shows both states of the anchor&#8230; the initial state at the &#8220;left top&#8221; and the hovered state &#8220;100px&#8221; from the left of the image. The following CSS code shows how you can reposition the background image to show a different image on hover &#8211; without the flicker:</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="css" style="color: #000000;">a <span class="br0">&#123;</span>
	<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">block</span><span class="sy0">;</span>
	<span class="kw1">padding</span><span class="sy0">:</span> <span class="re3">5px</span> <span class="re3">10px</span><span class="sy0">;</span>
	<span class="kw1">width</span><span class="sy0">:</span> <span class="re3">95px</span><span class="sy0">;</span>
	<span class="kw1">height</span><span class="sy0">:</span> <span class="re3">30px</span><span class="sy0">;</span>
	<span class="kw1">overflow</span><span class="sy0">:</span> <span class="kw2">hidden</span><span class="sy0">;</span>
	<span class="kw1">background</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span> <span class="kw2">url</span><span class="br0">&#40;</span><span class="re4">img/anchor_background<span class="re1">.gif</span></span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span> <span class="kw1">left</span> <span class="kw1">top</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#FFFFFF</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
a<span class="re2">:hover</span> <span class="br0">&#123;</span>
	<span class="kw1">background-position</span><span class="sy0">:</span> <span class="re3">100px</span> <span class="kw1">top</span><span class="sy0">;</span>
	<span class="kw1">background-color</span><span class="sy0">:</span> <span class="re0">#CCCCCC</span><span class="sy0">;</span>
	<span class="kw1">color</span><span class="sy0">:</span> <span class="re0">#<span class="nu0">000000</span></span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre></div></div></div>

<p>You may have to deal with all the anchor pseudo classes to get the effect consistent in all browsers, and be sure to define them in the correct order&#8230; :link, :visited, :hover, :active.</p>
<p>Finally, Internet Explorer only supports pseudo classes on the anchor element. All other browsers support pseudo classes on all elements. You could use this technique on non-anchor elements, but would be forced to introduce some javascript to support Internet Explorer. A good working example of this is the popular <a href="http://www.alistapart.com/articles/dropdowns">Suckerfish dropdowns</a> CSS menu solution that uses :hover on the list item element and attaches some javascript for Internet Explorer.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/10/create-rollovers-without-using-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing a disappearing caret in Firefox</title>
		<link>http://www.codecouch.com/2008/10/fixing-a-disappearing-caret-in-firefox/</link>
		<comments>http://www.codecouch.com/2008/10/fixing-a-disappearing-caret-in-firefox/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 12:45:53 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Firefox]]></category>

		<guid isPermaLink="false">http://www.codecouch.com/?p=178</guid>
		<description><![CDATA[The disappearing caret issue in Firefox is very annoying. There are many variations of this bug, most with fixes or workarounds. This fix is for the case where input elements on top of a fixed element do not have a caret.]]></description>
			<content:encoded><![CDATA[<p>There are many issues with Firefox hiding the caret (cursor) in text fields which have focus. There are various fixes, depending on the specifics of your issue, which mostly involve adding a style of &#8220;overflow:auto&#8221; to the input or container in question.</p>
<p>There is one case that doesn&#8217;t appear to have a fix, other than upgrading to Firefox 3: <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=230701">The cursor (caret) in a text input turns invisible when it is over a fixed element</a>. I&#8217;ve known about this problem for a while, and have tried many solutions that fixed similar issues, but they never seemed to work for this specific one.</p>
<p>I&#8217;ve found a solution that works, but it has 2 drawbacks:</p>
<ol>
<li>It requires JavaScript to work</li>
<li>It causes rendering errors on the fixed element when scrolling (almost as if the fixed element is scrolling as well)</li>
</ol>
<p>Using the test harness below, you can see the problem and the fix. I&#8217;ve included my test background image after the code, to make the rendering problem very obvious.</p>

<div class="wp_syntax_outer"><div class="wp_syntax"><div class="wp_syntax_inner"><pre class="html4strict" style="color: #000000;"><span class="sc0">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</span>
<span class="sc2"><span class="kw2">&lt;html</span> xmlns<span class="sy0">=</span><span class="st0">&quot;http://www.w3.org/1999/xhtml&quot;</span> <span class="kw3">dir</span><span class="sy0">=</span><span class="st0">&quot;ltr&quot;</span> <span class="kw3">lang</span><span class="sy0">=</span><span class="st0">&quot;en-US&quot;</span><span class="kw2">&gt;</span></span>
<span class="sc2"><span class="kw2">&lt;head</span> <span class="kw3">profile</span><span class="sy0">=</span><span class="st0">&quot;http://gmpg.org/xfn/11&quot;</span><span class="kw2">&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;meta</span> <span class="kw3">http-equiv</span><span class="sy0">=</span><span class="st0">&quot;content-type&quot;</span> <span class="kw3">content</span><span class="sy0">=</span><span class="st0">&quot;text/html; charset=UTF-8&quot;</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;meta</span> <span class="kw3">http-equiv</span><span class="sy0">=</span><span class="st0">&quot;content-language&quot;</span> <span class="kw3">content</span><span class="sy0">=</span><span class="st0">&quot;en&quot;</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;title&gt;</span></span>Disappearing caret bug - workaround<span class="sc2"><span class="kw2">&lt;/title&gt;</span></span>
&nbsp;
	<span class="sc2"><span class="kw2">&lt;style</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text/css&quot;</span><span class="kw2">&gt;</span></span>
		#fixedDiv {
			width: 100%;
			height: 100%;
			top: 0px;
			left: 0px;
			background: url(caretBugBg.gif);
			position: fixed;
		}
&nbsp;
		#contentDiv {
			position: relative;
		}
	<span class="sc2"><span class="kw2">&lt;/style&gt;</span></span>
&nbsp;
	<span class="sc2"><span class="kw2">&lt;script</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text/javascript&quot;</span><span class="kw2">&gt;</span></span>
		function fixCaretBug() {
			document.getElementById('fixedDiv').style.zIndex = -1;
			setTimeout(fixCaretBugPartTwo, 0);
		}
&nbsp;
		function fixCaretBugPartTwo() {
			document.getElementById('fixedDiv').style.zIndex = 0;
		}
	<span class="sc2"><span class="kw2">&lt;/script&gt;</span></span>
<span class="sc2"><span class="kw2">&lt;/head&gt;</span></span>
&nbsp;
<span class="sc2"><span class="kw2">&lt;body&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;fixedDiv&quot;</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
&nbsp;
	<span class="sc2"><span class="kw2">&lt;div</span> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;contentDiv&quot;</span><span class="kw2">&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;form&gt;</span></span>
			<span class="sc2"><span class="kw2">&lt;input</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text&quot;</span> <span class="kw3">size</span><span class="sy0">=</span><span class="st0">&quot;50&quot;</span> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">&quot;You cannot see the caret in this text input field...&quot;</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
			<span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
			<span class="sc2"><span class="kw2">&lt;input</span> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;button&quot;</span> <span class="kw3">value</span><span class="sy0">=</span><span class="st0">&quot;Click me to fix that!&quot;</span> <span class="kw3">onclick</span><span class="sy0">=</span><span class="st0">&quot;fixCaretBug();&quot;</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;/form&gt;</span></span>
&nbsp;
		<span class="sc2"><span class="kw2">&lt;p&gt;</span></span>This text...<span class="sc2"><span class="kw2">&lt;/p&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
&nbsp;
		<span class="sc2"><span class="kw2">&lt;p&gt;</span></span>is used...<span class="sc2"><span class="kw2">&lt;/p&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
&nbsp;
		<span class="sc2"><span class="kw2">&lt;p&gt;</span></span>to produce a vertical scrollbar.<span class="sc2"><span class="kw2">&lt;/p&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
&nbsp;
		<span class="sc2"><span class="kw2">&lt;p&gt;</span></span>If you cannot see a vertical scrollbar,<span class="sc2"><span class="kw2">&lt;/p&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
&nbsp;
		<span class="sc2"><span class="kw2">&lt;p&gt;</span></span>reduce the size of your browser window.<span class="sc2"><span class="kw2">&lt;/p&gt;</span></span>
		<span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span><span class="sc2"><span class="kw2">&lt;br</span> <span class="sy0">/</span><span class="kw2">&gt;</span></span>
	<span class="sc2"><span class="kw2">&lt;/div&gt;</span></span>
&nbsp;
<span class="sc2"><span class="kw2">&lt;/body&gt;</span></span>
<span class="sc2"><span class="kw2">&lt;/html&gt;</span></span></pre></div></div></div>

<p>There is a small flicker when the fix is enabled, although this could potentially be fixed by hooking into the DOMContentLoaded event and running the fix before the background image is loaded.</p>
<div id="attachment_182" class="wp-caption" style="width:300px;"><div style="font-size:0px;"><a href="http://www.codecouch.com/wp-content/uploads/2008/10/caretbugbg.gif"><img src="http://www.codecouch.com/wp-content/uploads/2008/10/caretbugbg-300x225.gif" alt="A grey rectangle with a black cross on top of it" title="Disappearing caret bug - workaround demo background image" width="300" height="225" class="size-medium wp-image-182" /></a></div><div class="seeThrough markupPod "><div class="seeThroughTop"><span class="tl"></span><span class="tr"></span><span class="t"></span></div><div class="seeThroughMiddle"><span class="r"></span><span class="l"></span><span class="m"></span><div class="seeThroughContent">
My test background image</div></div><div class="seeThroughBottom"><span class="bl"></span><span class="br"></span><span class="b"></span></div></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codecouch.com/2008/10/fixing-a-disappearing-caret-in-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
