<?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>Frederik Vig - ASP.NET developer &#187; Web design</title>
	<atom:link href="http://www.frederikvig.com/category/web-design/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.frederikvig.com</link>
	<description></description>
	<lastBuildDate>Wed, 28 Jul 2010 14:08:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Guide to font sizing with CSS</title>
		<link>http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=guide-to-font-sizing-with-css</link>
		<comments>http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 09:23:55 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1057</guid>
		<description><![CDATA[Font sizing with CSS and browser support as always been a mystery to me. We used to use pixels, than we switched to ems and percent, then we switched back to pixels again?!.. In this post I&#8217;ve tried shedding some light on the matter and explaining the reason for this, and the different ways of [...]]]></description>
			<content:encoded><![CDATA[<p>Font sizing with CSS and browser support as always been a mystery to me. We used to use pixels, than we switched to ems and percent, then we switched back to pixels again?!.. In this post I&#8217;ve tried shedding some light on the matter and explaining the reason for this, and the different ways of doing font sizing on the web. </p>
<p>You have quite a few different measuring units to use in CSS for use with the font-size property (em, ex, px, in, cm, mm, pt, pc, %). We can group these lengths into two groups.</p>
<h3>Relative lenghts</h3>
<ul>
<li>em: the &#8216;font-size&#8217; of the relevant font</li>
<li>ex: the &#8216;x-height&#8217; of the relevant font</li>
<li>px: pixels, relative to the viewing device (resolution and pixel density)</li>
</ul>
<h3>Absolute lengths</h3>
<ul>
<li>in: inches — 1 inch is equal to 2.54 centimeters.</li>
<li>cm: centimeters</li>
<li>mm: millimeters</li>
<li>pt: points — the points used by CSS 2.1 are equal to 1/72nd of an inch.</li>
<li>pc: picas — 1 pica is equal to 12 points.</li>
</ul>
<p>Percentage values are always relative to a length or other value.</p>
<p>To be honest I only use four of these units. I use points (pt) in my print stylesheet, and px, em and % for my screen stylesheet. </p>
<h3>Pixels</h3>
<p>When using pixels for your font size you don&#8217;t have much to think about, 12px is 12px in every browser. What can be a problem, and what is the main reason that organizations like the <a href="http://www.w3.org">W3C</a> advice against using pixels for font size measurement, is the lack of support in browsers like Internet Explorer 6 when changing the browser&#8217;s default font size. The reason for this is that most browsers used to use text scaling for this, only enlarging the text on the page. However the newest versions of all the major browsers now use page zooming instead. What this does is increase (or decrease) all the elements on the page, not just the text, by zooming. </p>
<p>Lack of support for page zooming in Internet Explorer 6 can be a problem. If it is you should consider using ems and percent, which all browsers support. You can use ems/percent either for all browsers or by using a conditional comment stylesheet for Internet Explorer 6 and using pixels for the rest. I personally have started using pixels again, simple because it saves me a ton of work, and is much more reliable for measurement than using % and ems.</p>
<h3>Ems and percent</h3>
<p>If your audience still consists of a lot of Internet Explorer 6 users, you might want to stick with using ems or % for measurement. The rule to follow here is <strong>target &divide; context = result</strong>.</p>
<h4>Example</h4>
<p>If we give body a font size of 100% (roughly around 16px in most browsers), we can use that as the context. So if we want 12px in font size for normal text, and 20px for headings, this then becomes the target.</p>
<ul>
<li>12 &divide; 16 = 0,75</li>
<li>20 &divide; 16 = 1,25</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
p <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">.75em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
h1 <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.25em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>If we&#8217;d used pixels we would have something like this.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">p <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
h1 <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Okay, say we have some text inside our paragraphs that we want to be 13px. The target becomes 13px, but the context changes, instead of using the body as the context, the paragraph becomes the context. So we get 13 &divide; 12 = 1,0833.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">p strong <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1.0833em</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>By using the <strong>target &divide; context = result</strong> rule, everything comes down to maths <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Here is the live example with <a href="http://www.frederikvig.com/wp-content/uploads/font-sizing/font-sizing.html">ems and percent</a> and here with <a href="http://www.frederikvig.com/wp-content/uploads/font-sizing/font-sizing-px.html">pixels</a>.</p>
<p>So, what are you using?<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/10/font-resizing-and-printing-with-jquery/" rel="bookmark" title="October 27, 2009">Font resizing and printing with jQuery</a></li>
<li><a href="http://www.frederikvig.com/2009/05/css-tricks-part-1/" rel="bookmark" title="May 31, 2009">CSS tricks &#8211; part 1</a></li>
<li><a href="http://www.frederikvig.com/2010/04/episerver-file-manager-and-file-summary/" rel="bookmark" title="April 2, 2010">EPiServer File Manager and File Summary</a></li>
<li><a href="http://www.frederikvig.com/2009/05/transparent-pngs/" rel="bookmark" title="May 5, 2009">Transparent PNGs</a></li>
<li><a href="http://www.frederikvig.com/2009/08/adding-css-and-javascript-files-dynamically-to-your-asp-net-page/" rel="bookmark" title="August 15, 2009">Adding CSS and JavaScript files dynamically to your ASP.NET page</a></li>
</ul>
<p><!-- Similar Posts took 10.060 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Better breadcrumb trail</title>
		<link>http://www.frederikvig.com/2009/11/better-breadcrumb-trail/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=better-breadcrumb-trail</link>
		<comments>http://www.frederikvig.com/2009/11/better-breadcrumb-trail/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 12:39:12 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=416</guid>
		<description><![CDATA[I often install the Public Templates when setting up a new EPiServer project. They contain some good code that I reuse in various parts of a new site. One thing that I&#8217;ve copied and modified is the code for the breadcrumb (breadcrumb.ascx). By default the markup rendered looks something like this. &#60;a href=&#34;/en/&#34; title=&#34;To start [...]]]></description>
			<content:encoded><![CDATA[<p>I often install the Public Templates when setting up a new EPiServer project. They contain some good code that I reuse in various parts of a new site. One thing that I&#8217;ve copied and modified is the code for the breadcrumb (breadcrumb.ascx). By default the markup rendered looks something like this.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&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;/en/&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;To start page&quot;</span>&gt;</span>Start<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span> / 
<span style="color: #009900;">&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;/en/Events/&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Events&quot;</span>&gt;</span>Events<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span> / 
<span style="color: #009900;">&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;/en/Events/Conference/&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Conference&quot;</span>&gt;</span>Conference<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></div></div>

<p>There are a number of problems with this code. First of the markup is not very semantic. Second the title attribute is redundant, since the same text gets repeated twice, and thus read by screen readers twice. Third the page we&#8217;re currently on should not be a link, since we&#8217;re already on it. It should also have some help text for screen reader users giving information that &#8220;Conference&#8221; in fact is the current page.</p>
<h3>Better markup</h3>
<p>Okay lets fix the semantics first. Lets put the links inside a list and remove the forward slash (/), which is presentational, something that should be handled by CSS.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ul</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</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;/en/&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;To start page&quot;</span>&gt;</span>Start<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;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</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;/en/Events/&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Events&quot;</span>&gt;</span>Events<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;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</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;/en/Events/Conference/&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Conference&quot;</span>&gt;</span>Conference<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;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ul</span>&gt;</span></pre></div></div>

<p>This is better, but we&#8217;re not quite there yet. An unordered list is not the correct list type here. The meaning of the list changes when we change the order of the links, we should therefor use an ordered list instead. Lets update the list to be ordered, and lets also get rid of all the title attributes.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">ol</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</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;/en/&quot;</span>&gt;</span>Start<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;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</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;/en/Events/&quot;</span>&gt;</span>Events<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;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</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;/en/Events/Conference/&quot;</span>&gt;</span>Conference<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;">li</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">ol</span>&gt;</span></pre></div></div>

<p>That&#8217;s better! Now we only have the &#8220;Conference&#8221; link left. Lets remove the anchor, and add some helper text for our screen reader users.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">...
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">li</span>&gt;</span>Conference <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">span</span>&gt;</span>(this page)<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">span</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">li</span>&gt;</span>
...</pre></div></div>

<h3>A little styling</h3>
<p>Great, now with a little CSS we can transform this to a nice, user friendly breadcrumb trail.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#breadcrumb</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#breadcrumb</span> li <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#breadcrumb</span> a
<span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#3e3e3e</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">.5em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1em</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">images/separator.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> <span style="color: #000000; font-weight: bold;">right</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#breadcrumb</span> span <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-9999px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Nothing particular here, instead of adding extra markup for the separator, we&#8217;re using a background image. And for the helper text we&#8217;re using a technique for pushing the span element all the way to the left (off screen), hiding it from all except screen reader users. Why not use display: none instead? Well because some screen readers don&#8217;t read text that has the display property set to none.</p>
<h3>The result</h3>
<p><img src="http://www.frederikvig.com/wp-content/uploads/breadcrumb.png" alt="" /><br />
Nothing exciting here, but we now have a much more semantic breadcrumb, that is very easy to style to our needs.</p>
<h3>Implementation in EPiServer</h3>
<p>This is code based on the Public Templates breadcrumb.ascx, modified for our purpose.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">EPiServer.Core</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Text</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> EPiServer.<span style="color: #0000FF;">Templates</span>.<span style="color: #0600FF;">Public</span>.<span style="color: #0000FF;">Units</span>.<span style="color: #0600FF;">Static</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">partial</span> <span style="color: #FF0000;">class</span> BreadCrumbs <span style="color: #008000;">:</span> UserControlBase
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">const</span> <span style="color: #FF0000;">string</span> _link <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&lt;li&gt;&lt;a href=<span style="color: #008080; font-weight: bold;">\&quot;</span>{0}<span style="color: #008080; font-weight: bold;">\&quot;</span>&gt;{1}&lt;/a&gt;&lt;/li&gt;&quot;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">int</span> _maxLength <span style="color: #008000;">=</span> <span style="color: #FF0000;">60</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> _breadcrumbId <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;breadcrumb&quot;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> OnPreRender<span style="color: #000000;">&#40;</span>EventArgs e<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Breadcrumbs.<span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> GenerateBreadCrumbs<span style="color: #000000;">&#40;</span>CurrentPage<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> GenerateBreadCrumbs<span style="color: #000000;">&#40;</span>PageData page<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// Initiate a string builder based on max length. The generated html is considerably longer than the visible text.</span>
            var breadCrumbsText <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> StringBuilder<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">8</span> <span style="color: #008000;">*</span> MaxLength<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// Initiate a counter holding the visible length of the bread crumbs with the length of the start page link text.</span>
            <span style="color: #FF0000;">int</span> breadCrumbsLength <span style="color: #008000;">=</span> Translate<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;/navigation/startpage&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>page <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">!</span>page.<span style="color: #0000FF;">PageLink</span>.<span style="color: #0000FF;">CompareToIgnoreWorkID</span><span style="color: #000000;">&#40;</span>PageReference.<span style="color: #0000FF;">StartPage</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                breadCrumbsLength <span style="color: #008000;">+=</span> page.<span style="color: #0000FF;">PageName</span>.<span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>breadCrumbsLength <span style="color: #008000;">&gt;</span> MaxLength<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    breadCrumbsText.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #666666;">&quot;...&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    break<span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// Insert the link at beginning of the bread crumbs string </span>
                breadCrumbsText.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">GetLink</span><span style="color: #000000;">&#40;</span>page<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #008080; font-style: italic;">// Get next visible parent</span>
                page <span style="color: #008000;">=</span> <span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">GetParentPageData</span><span style="color: #000000;">&#40;</span>page<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// Generate the start page link </span>
            <span style="color: #FF0000;">string</span> startPageLinkUrl <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #000000;">&#40;</span>startPageLinkUrl<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                startPageLinkUrl <span style="color: #008000;">=</span> Server.<span style="color: #0000FF;">UrlPathEncode</span><span style="color: #000000;">&#40;</span>GetPage<span style="color: #000000;">&#40;</span>PageReference.<span style="color: #0000FF;">StartPage</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">LinkURL</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #FF0000;">string</span> startPageLink <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span>_link, startPageLinkUrl, Translate<span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;/navigation/startpage&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            breadCrumbsText.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, startPageLink<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #FF0000;">string</span> listStart <span style="color: #008000;">=</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;ol id=<span style="color: #008080; font-weight: bold;">\&quot;</span>{0}<span style="color: #008080; font-weight: bold;">\&quot;</span>&quot;</span>, _breadcrumbId<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            breadCrumbsText.<span style="color: #0000FF;">Insert</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, listStart<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            breadCrumbsText.<span style="color: #0000FF;">Append</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;/ol&gt;&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">return</span> breadCrumbsText.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Get the next visible parent page of the supplied &lt;see cref=&quot;PageData&quot;/&gt;. </span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;page&quot;&gt;&lt;/param&gt;</span>
        <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;The &lt;see cref=&quot;PageData&quot;/&gt; object or    &lt;/returns&gt;</span>
        <span style="color: #0600FF;">private</span> PageData GetParentPageData<span style="color: #000000;">&#40;</span>PageData pageData<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #008080; font-style: italic;">// Don't return a PageData object for start page or root page.</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>pageData <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span> <span style="color: #008000;">||</span> pageData.<span style="color: #0000FF;">ParentLink</span> <span style="color: #008000;">==</span> PageReference.<span style="color: #0000FF;">StartPage</span> <span style="color: #008000;">||</span> pageData.<span style="color: #0000FF;">ParentLink</span> <span style="color: #008000;">==</span> PageReference.<span style="color: #0000FF;">RootPage</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">return</span> null<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// Get Page data for parent page</span>
            pageData <span style="color: #008000;">=</span> GetPage<span style="color: #000000;">&#40;</span>pageData.<span style="color: #0000FF;">ParentLink</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>pageData <span style="color: #008000;">!=</span> <span style="color: #0600FF;">null</span> <span style="color: #008000;">&amp;&amp;</span> pageData.<span style="color: #0000FF;">VisibleInMenu</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">return</span> pageData<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
            <span style="color: #008080; font-style: italic;">// Step up to next parent</span>
            <span style="color: #0600FF;">return</span> GetParentPageData<span style="color: #000000;">&#40;</span>pageData<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Returns a anchor based on a &lt;see cref=&quot;PageData&quot;/&gt; object.</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #FF0000;">string</span> GetLink<span style="color: #000000;">&#40;</span>PageData page<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #FF0000;">string</span> pageName <span style="color: #008000;">=</span> page.<span style="color: #0000FF;">Property</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;PageName&quot;</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">ToWebString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>page.<span style="color: #0000FF;">PageLink</span>.<span style="color: #0000FF;">CompareToIgnoreWorkID</span><span style="color: #000000;">&#40;</span>CurrentPage.<span style="color: #0000FF;">PageLink</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">return</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;&lt;li&gt;{0} &lt;span&gt;(this page)&lt;/span&gt;&lt;/li&gt;&quot;</span>, pageName<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF;">return</span> <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span>_link, Server.<span style="color: #0000FF;">UrlPathEncode</span><span style="color: #000000;">&#40;</span>page.<span style="color: #0000FF;">LinkURL</span><span style="color: #000000;">&#41;</span>, pageName<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
        <span style="color: #008080; font-style: italic;">/// Sets the max length on the visible breadcrumb text (default = 60)</span>
        <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">int</span> MaxLength
        <span style="color: #000000;">&#123;</span>
            get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _maxLength<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
            set <span style="color: #000000;">&#123;</span> _maxLength <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> BreadcrumbId
        <span style="color: #000000;">&#123;</span>
            get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _breadcrumbId<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
            set <span style="color: #000000;">&#123;</span> _breadcrumbId <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>One thing to note here is that I&#8217;ve hard coded the text (this page). This should be placed in a language file instead.</p>
<h3>Other resources</h3>
<ul>
<li><a href="http://www.smashingmagazine.com/2009/03/17/breadcrumbs-in-web-design-examples-and-best-practices-2/">Breadcrumbs In Web Design: Examples And Best Practices</a></li>
</ul>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/09/creating-a-custom-episerver-paging-control/" rel="bookmark" title="September 20, 2009">Creating a Custom EPiServer Paging Control</a></li>
<li><a href="http://www.frederikvig.com/2009/08/adding-css-and-javascript-files-dynamically-to-your-asp-net-page/" rel="bookmark" title="August 15, 2009">Adding CSS and JavaScript files dynamically to your ASP.NET page</a></li>
<li><a href="http://www.frederikvig.com/2009/05/episerver-extension-methods/" rel="bookmark" title="May 4, 2009">EPiServer Extension Methods</a></li>
<li><a href="http://www.frederikvig.com/2009/07/episerver-web-controls-property/" rel="bookmark" title="July 5, 2009">EPiServer web controls: Property</a></li>
<li><a href="http://www.frederikvig.com/2010/03/starting-out-with-xslt-in-umbraco/" rel="bookmark" title="March 20, 2010">Starting out with XSLT in Umbraco</a></li>
</ul>
<p><!-- Similar Posts took 11.895 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2009/11/better-breadcrumb-trail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Font resizing and printing with jQuery</title>
		<link>http://www.frederikvig.com/2009/10/font-resizing-and-printing-with-jquery/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=font-resizing-and-printing-with-jquery</link>
		<comments>http://www.frederikvig.com/2009/10/font-resizing-and-printing-with-jquery/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 21:00:35 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=360</guid>
		<description><![CDATA[You&#8217;ve probably seen the three A&#8217;s on various websites, especially public sector websites; that you can click on to increase the font size on the web site. I&#8217;m personally not a huge fan of those. In my opinion it is much better to explain to the user how they can use the built in browser [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve probably seen the three A&#8217;s on various websites, especially public sector websites; that you can click on to increase the font size on the web site. I&#8217;m personally not a huge fan of those. In my opinion it is much better to explain to the user how they can use the built in browser functionality to do this instead. This will also increase the font size on all websites not just the one you created. You could do this by linking to a page with an explanation and screenshots of how to do this in the most popular browsers. </p>
<p>However sometimes I still need to create those three A&#8217;s. Below is a little jQuery plugin that does this.</p>
<p><a href="http://www.frederikvig.com/wp-content/uploads/fontresizing-print-plugin/demo.html">See the demo</a></p>
<h3>Font resizing plugin</h3>
<p>This plugin will create an ordered list with three links to increase the font size. The plugin adds three different classes to the body element, which then can be used to set the base font size.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">body<span style="color: #6666ff;">.small</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">80</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body<span style="color: #6666ff;">.medium</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">120</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body<span style="color: #6666ff;">.large</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">140</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>The plugin code.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><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: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>customOptions<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span>.<span style="color: #660066;">defaultOptions</span><span style="color: #339933;">,</span> customOptions<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> bodyClasses <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">smallClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">mediumClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">largeClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</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;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;ol class=&quot;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">fontresizingClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;&lt;li&gt;&lt;a href=&quot;&quot; class=&quot;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">smallClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;A&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;&quot; class=&quot;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">mediumClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;A&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;&quot; class=&quot;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">largeClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;A&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ol.'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">fontresizingClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</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: #003366; font-weight: bold;">var</span> cssClass <span style="color: #339933;">=</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;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span>bodyClasses<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span>cssClass<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                createCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fontresizingClass'</span><span style="color: #339933;">,</span> cssClass<span style="color: #339933;">,</span> options.<span style="color: #660066;">cookieDuration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">var</span> fontresizingClass <span style="color: #339933;">=</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fontresizingClass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fontresizingClass <span style="color: #339933;">==</span> options.<span style="color: #660066;">smallClass</span> <span style="color: #339933;">||</span> fontresizingClass <span style="color: #339933;">==</span> options.<span style="color: #660066;">mediumClass</span> <span style="color: #339933;">||</span> fontresizingClass <span style="color: #339933;">==</span> options.<span style="color: #660066;">largeClass</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span>bodyClasses<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span>fontresizingClass<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// cookie functions http://www.quirksmode.org/js/cookies.html</span>
            <span style="color: #003366; font-weight: bold;">function</span> createCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #339933;">,</span> value<span style="color: #339933;">,</span> days<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>days<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    date.<span style="color: #660066;">setTime</span><span style="color: #009900;">&#40;</span>date.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>days <span style="color: #339933;">*</span> <span style="color: #CC0000;">24</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;; expires=&quot;</span> <span style="color: #339933;">+</span> date.<span style="color: #660066;">toGMTString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
                document.<span style="color: #660066;">cookie</span> <span style="color: #339933;">=</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span> <span style="color: #339933;">+</span> value <span style="color: #339933;">+</span> expires <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;; path=/&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">function</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> nameEQ <span style="color: #339933;">=</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #003366; font-weight: bold;">var</span> ca <span style="color: #339933;">=</span> document.<span style="color: #660066;">cookie</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">';'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> ca.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> ca<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span> c <span style="color: #339933;">=</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>nameEQ<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>nameEQ.<span style="color: #660066;">length</span><span style="color: #339933;">,</span> c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</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: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span>.<span style="color: #660066;">defaultOptions</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        smallClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'small'</span><span style="color: #339933;">,</span>
        mediumClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'medium'</span><span style="color: #339933;">,</span>
        largeClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'large'</span><span style="color: #339933;">,</span>
        fontresizingClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'font-resizing'</span><span style="color: #339933;">,</span>
        cookieDuration<span style="color: #339933;">:</span> <span style="color: #CC0000;">365</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h4>Breaking it down</h4>
<p>We start by creating a private scope for our jQuery code. The reason for this is so we don&#8217;t have to worry about conflicts with other libraries.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><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;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We then add a new method to the jQuery.fn object</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><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: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>customOptions<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    ...
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Combine the custom options with the default options.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><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: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>customOptions<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span>.<span style="color: #660066;">defaultOptions</span><span style="color: #339933;">,</span> customOptions<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        ...
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span>.<span style="color: #660066;">defaultOptions</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        smallClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'small'</span><span style="color: #339933;">,</span>
        mediumClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'medium'</span><span style="color: #339933;">,</span>
        largeClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'large'</span><span style="color: #339933;">,</span>
        fontresizingClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'font-resizing'</span><span style="color: #339933;">,</span>
        cookieDuration<span style="color: #339933;">:</span> <span style="color: #CC0000;">365</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Next we iterate over the jQuery object or jQuery wrapper set, and return &#8220;this&#8221; (the current jQuery object), so we don&#8217;t break the jQuery chaining functionality.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><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: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>customOptions<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span>.<span style="color: #660066;">defaultOptions</span><span style="color: #339933;">,</span> customOptions<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> bodyClasses <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">smallClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">mediumClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">largeClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</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;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span>.<span style="color: #660066;">defaultOptions</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        smallClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'small'</span><span style="color: #339933;">,</span>
        mediumClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'medium'</span><span style="color: #339933;">,</span>
        largeClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'large'</span><span style="color: #339933;">,</span>
        fontresizingClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'font-resizing'</span><span style="color: #339933;">,</span>
        cookieDuration<span style="color: #339933;">:</span> <span style="color: #CC0000;">365</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now we come to the actual code for creating the links and attaching click events to them.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><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: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>customOptions<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span>.<span style="color: #660066;">defaultOptions</span><span style="color: #339933;">,</span> customOptions<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> bodyClasses <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">smallClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">mediumClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' '</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">largeClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</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;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;ol class=&quot;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">fontresizingClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;&lt;li&gt;&lt;a href=&quot;&quot; class=&quot;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">smallClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;A&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;&quot; class=&quot;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">mediumClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;A&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;&quot; class=&quot;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">largeClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;A&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ol.'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">fontresizingClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</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: #003366; font-weight: bold;">var</span> cssClass <span style="color: #339933;">=</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;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span>bodyClasses<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span>cssClass<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                createCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fontresizingClass'</span><span style="color: #339933;">,</span> cssClass<span style="color: #339933;">,</span> options.<span style="color: #660066;">cookieDuration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</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>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #660066;">fontresizing</span>.<span style="color: #660066;">defaultOptions</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        smallClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'small'</span><span style="color: #339933;">,</span>
        mediumClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'medium'</span><span style="color: #339933;">,</span>
        largeClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'large'</span><span style="color: #339933;">,</span>
        fontresizingClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'font-resizing'</span><span style="color: #339933;">,</span>
        cookieDuration<span style="color: #339933;">:</span> <span style="color: #CC0000;">365</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Lastly we have the cookie functions to read and create the cookie to hold the font size choices the user has made.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">...
            <span style="color: #003366; font-weight: bold;">var</span> fontresizingClass <span style="color: #339933;">=</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fontresizingClass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fontresizingClass <span style="color: #339933;">==</span> options.<span style="color: #660066;">smallClass</span> <span style="color: #339933;">||</span> fontresizingClass <span style="color: #339933;">==</span> options.<span style="color: #660066;">mediumClass</span> <span style="color: #339933;">||</span> fontresizingClass <span style="color: #339933;">==</span> options.<span style="color: #660066;">largeClass</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span>bodyClasses<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span>fontresizingClass<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// cookie functions from http://www.quirksmode.org/js/cookies.html</span>
            <span style="color: #003366; font-weight: bold;">function</span> createCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #339933;">,</span> value<span style="color: #339933;">,</span> days<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>days<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    date.<span style="color: #660066;">setTime</span><span style="color: #009900;">&#40;</span>date.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>days <span style="color: #339933;">*</span> <span style="color: #CC0000;">24</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">60</span> <span style="color: #339933;">*</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;; expires=&quot;</span> <span style="color: #339933;">+</span> date.<span style="color: #660066;">toGMTString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
                document.<span style="color: #660066;">cookie</span> <span style="color: #339933;">=</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span> <span style="color: #339933;">+</span> value <span style="color: #339933;">+</span> expires <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;; path=/&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">function</span> readCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> nameEQ <span style="color: #339933;">=</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #003366; font-weight: bold;">var</span> ca <span style="color: #339933;">=</span> document.<span style="color: #660066;">cookie</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">';'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> ca.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> ca<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span> c <span style="color: #339933;">=</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>nameEQ<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>nameEQ.<span style="color: #660066;">length</span><span style="color: #339933;">,</span> c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<h4>Usage</h4>
<p>To use the plugin simply add a reference to the jQuery library file, and copy the code into your page. After you&#8217;ve done that you can use it by calling the fontresizing method</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// With default options</span>
jQuery<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: #3366CC;">'#tools'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fontresizing</span><span style="color: #009900;">&#40;</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>
&nbsp;
<span style="color: #006600; font-style: italic;">// With custom options</span>
jQuery<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: #3366CC;">'#tools'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fontresizing</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        smallClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'small'</span><span style="color: #339933;">,</span>
        mediumClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'medium'</span><span style="color: #339933;">,</span>
        largeClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'large'</span><span style="color: #339933;">,</span>
        fontresizingClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'font-resizing'</span><span style="color: #339933;">,</span>
        cookieDuration<span style="color: #339933;">:</span> <span style="color: #CC0000;">365</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></div></div>

<h3>Print plugin</h3>
<p>Another thing that many clients ask for is a print link. Below is a little jQuery plugin that creates the link and attaches a click event that triggers the browsers print dialog.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><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: #660066;">fn</span>.<span style="color: #000066;">print</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>customOptions<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> options <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> $.<span style="color: #660066;">fn</span>.<span style="color: #000066;">print</span>.<span style="color: #660066;">defaultOptions</span><span style="color: #339933;">,</span> customOptions<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</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;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;a href=&quot;&quot; class=&quot;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">printClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">printText</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.'</span> <span style="color: #339933;">+</span> options.<span style="color: #660066;">printClass</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</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>
                window.<span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</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>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    $.<span style="color: #660066;">fn</span>.<span style="color: #000066;">print</span>.<span style="color: #660066;">defaultOptions</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        printClass<span style="color: #339933;">:</span> <span style="color: #3366CC;">'print'</span><span style="color: #339933;">,</span>
        printText<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Print'</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Here we also generate the link with JavaScript, so that users who don&#8217;t have JavaScript wont see it &#8211; since they cannot use it anyway. When you click on the link you&#8217;ll see the print dialog; use this with CSS to create a printer friendly version of your page.</p>
<p>To create CSS rules for print either use the <a href="http://reference.sitepoint.com/css/at-media">@media</a></p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@media print {</span>
  <span style="color: #808080; font-style: italic;">/* CSS rules here */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>or link to an external CSS file and add the media=&#8221;print&#8221; attribute.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;styles/print.css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;print&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<h4>Usage</h4>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// With default options</span>
jQuery<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: #3366CC;">'#tools'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">print</span><span style="color: #009900;">&#40;</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>
&nbsp;
<span style="color: #006600; font-style: italic;">// With custom options</span>
jQuery<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: #3366CC;">'#tools'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        printText<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Print this page'</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></div></div>

<p>Download the code or <a href="http://www.frederikvig.com/wp-content/uploads/fontresizing-print-plugin/demo.html">see the demo</a></p>
<ul>
<li><a href="http://www.frederikvig.com/wp-content/uploads/fontresizing-print-plugin/jquery.fontresizing.js">jquery.fontresizing.js</a></li>
<li><a href="http://www.frederikvig.com/wp-content/uploads/fontresizing-print-plugin/jquery.print.js">jquery.print.js</a></li>
</ul>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/07/asp-net-web-forms-and-jquery-thickbox-plugin/" rel="bookmark" title="July 13, 2009">ASP.NET web forms and jQuery Thickbox plugin</a></li>
<li><a href="http://www.frederikvig.com/2009/05/aspnet-validation-and-jquery/" rel="bookmark" title="May 21, 2009">ASP.NET Validation and jQuery</a></li>
<li><a href="http://www.frederikvig.com/2009/05/transparent-pngs/" rel="bookmark" title="May 5, 2009">Transparent PNGs</a></li>
<li><a href="http://www.frederikvig.com/2009/05/measuring-javascript-performance/" rel="bookmark" title="May 10, 2009">Measuring JavaScript performance</a></li>
<li><a href="http://www.frederikvig.com/2010/04/backup-plan-when-loading-the-jquery-library-from-cdn/" rel="bookmark" title="April 20, 2010">Backup plan when loading the jQuery library from CDN</a></li>
</ul>
<p><!-- Similar Posts took 8.996 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2009/10/font-resizing-and-printing-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a mobile version of a web site</title>
		<link>http://www.frederikvig.com/2009/10/creating-a-mobile-version-of-a-web-site/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=creating-a-mobile-version-of-a-web-site</link>
		<comments>http://www.frederikvig.com/2009/10/creating-a-mobile-version-of-a-web-site/#comments</comments>
		<pubDate>Sun, 04 Oct 2009 17:51:31 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=244</guid>
		<description><![CDATA[When building web sites we has developers or designers have to take into consideration all the different types of devices that can be used to access the web sites we create. Not just PC or Mac with Internet Explorer, Firefox, Safari, Opera, Jaws, or any other browser. But also mobile devices, like iPhones, iTouch, Nintendo [...]]]></description>
			<content:encoded><![CDATA[<p>When building web sites we has developers or designers have to take into consideration all the different types of devices that can be used to access the web sites we create. Not just PC or Mac with Internet Explorer, Firefox, Safari, Opera, Jaws, or any other browser. But also mobile devices, like iPhones, iTouch, Nintendo Wii. </p>
<p>Especially in recent years, after the launch of the iPhone, accessing online information through a mobile device has become more common. This is something that is going to increase even more in the next few years.</p>
<p>Below I&#8217;ve listed some resources for creating a mobile version of a web site that I hope you&#8217;ll find useful.</p>
<h3>Mobify</h3>
<p><a href="http://mobify.me/">Mobify</a> is a free online service that lets you convert an existing web site into a mobile version. This is done by selecting the content you wish to display for mobile users, customizing it by changing the display order and tweaking the CSS. The last step is to publish it by creating an url and adding a little JavaScript to your page. </p>
<p>Check out <a href="http://woork.blogspot.com/2009/08/how-to-implement-mobile-version-of-your.html">How to implement a mobile version of your blog in three simple steps</a> for a quick introduction.</p>
<p>Mobify is quick and easy way to great a mobile version, but you cannot change the HTML code and you&#8217;re stuck with the options the service offers. It can sometimes be better to create a mobile version from scratch.</p>
<h4>Update 05.10.2009</h4>
<p>Igor Faletski, founder of <a href="http://www.mobify.me">Mobify</a>, was kind enough to send me an email explaining the use of HTML blocks to add more static content. While this is a great feature I still miss the ability to update my existing markup and easily see what classes and ids that the mobile version uses. Now I have to test and tweak a little before I get the right id or class when changing my CSS.</p>
<h3>Creating a mobile version with ASP.NET</h3>
<p>Although services like Mobify are great, sometimes you need full control. On <a href="http://www.mobify.me/">mobify.me</a> it says that Mobify supports over 4500+ different mobile devices. This is a lot of different devices to support! Fortunately there is an open source project on CodePlex that has done most of the work for us. It is called <a href="http://mdbf.codeplex.com/">Mobile Device Browser File</a> and consists of a browser file with information about what the different mobile devices support (Java, JavaScript, Images, Flash etc). This project is pretty active with new devices added all the time. </p>
<p>You simply download the browser file and add it to your projects App_Browser folder. After you&#8217;ve done that you&#8217;ll be able to use Request.Browser["IsMobileDevice"] to detect if the device accessing your page is actually a mobile device. There are also <a href="http://mdbf.codeplex.com/Wiki/View.aspx?title=Capabilities&#038;referringTitle=Home">64 other capabilities</a> that offers a lot of different detection functionality. You can for instance check if the device supports Flash, JavaScript, Color, CSS background images etc.</p>
<p>If you&#8217;re using ASP.NET MVC check out <a href="http://www.hanselman.com/blog/MixMobileWebSitesWithASPNETMVCAndTheMobileBrowserDefinitionFile.aspx">Scott Hanselman&#8217;s post about how he implemented this with Nerd Dinner</a>. </p>
<p>If you&#8217;re using ASP.NET web forms there are a couple of approaches you could take. You could use a different master page for the mobile version by adding some detection code to your base page and <a href="http://odetocode.com/Articles/450.aspx">switching the master pages in the Init method</a>. Or you could register a <a href="http://msdn.microsoft.com/en-us/library/ms227673.aspx">custom HttpModule</a> that redirects the user to a different page if it is a mobile device.</p>
<p>Recently I stumbled over another library to detect the mobile device, it is called <a href="http://www.51degrees.mobi/Products/NETMobileAPI">51Degrees.mobi</a>. <a href="http://dotnetslackers.com/articles/aspnet/Mobile-Device-Detection-and-Redirection-Using-ASP-NET.aspx">Here is the article</a> that describes how to use it.</p>
<h3>iPhone</h3>
<p>Apple iPhone uses the Safari browser as its default browser. The great thing about that is that CSS3 stuff like <a href="http://www.css3.info/preview/rounded-border.html">border-radius</a>, multiple background images, <a href="http://furbo.org/2007/07/11/quartz-and-JavaScript-sitting-in-a-tree/">canvas</a> and more are supported. </p>
<p>If you like to simply target iPhone users you can do so by simply adding a custom stylesheet with this code.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;only screen and (max-device-width: 480px)&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;iPhone.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p>For more information I recommend reading <a href="http://www.alistapart.com/articles/putyourcontentinmypocket/">A List Aparts Put Your Content in My Pocket</a> and checking out the <a href="http://developer.apple.com/iphone/">iPhone Dev Center</a>.</p>
<h3>WordPress</h3>
<p>For WordPress you have a nice plugin called <a href="http://www.bravenewcode.com/wptouch/">WPtouch</a>, that will help you easily add a mobile view for iPhone, iPod, Android, Storm and Pre. You just need to install and activate the plugin, and you&#8217;re ready! You can easily customize it to your needs as well. </p>
<h3>Other resources</h3>
<p>More and more resources are being added each day. Below are some I&#8217;ve bookmarked and that have helped me in the past.</p>
<ul>
<li><a href="http://quirksmode.org/m/">Quirksmode great set of mobile tests</li>
<li><a href="http://mobify.me/">Mobify easily turn an existing site into a mobile view</a></li>
<li><a href="http://mobilewebbook.com/">Cameron Molls book about mobile web design</a></li>
<li><a href="http://mdbf.codeplex.com/">Mobile Device Browser File</a></li>
<li><a href="http://www.w3.org/Mobile/">W3C Mobile Web Initiative</a></li>
<li><a href="http://www.w3.org/TR/mwabp/">W3C Mobile Web Application Best Practices</a></li>
<li><a href="http://ready.mobi/launch.jsp?locale=en_EN">Test your website for mobile compatibility</a></li>
</ul>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2009/07/asp-net-web-forms-and-jquery-thickbox-plugin/" rel="bookmark" title="July 13, 2009">ASP.NET web forms and jQuery Thickbox plugin</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-1-setting-up-the-development-environment-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 4, 2009">Part 1: Setting up the development environment &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-8-preparing-for-launch-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 24, 2009">Part 8: Preparing for launch – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/introduction-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 1, 2009">Introduction &#8211; Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2010/04/creating-a-simple-image-gallery-with-episerver/" rel="bookmark" title="April 3, 2010">Creating a simple image gallery with EPiServer</a></li>
</ul>
<p><!-- Similar Posts took 15.486 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2009/10/creating-a-mobile-version-of-a-web-site/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CSS tricks &#8211; part 1</title>
		<link>http://www.frederikvig.com/2009/05/css-tricks-part-1/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=css-tricks-part-1</link>
		<comments>http://www.frederikvig.com/2009/05/css-tricks-part-1/#comments</comments>
		<pubDate>Sun, 31 May 2009 14:52:55 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=49</guid>
		<description><![CDATA[Here are a few CSS tricks I&#8217;ve picked up along the way. Always visible vertical scrollbar When you have a fixed width centered web site open you&#8217;ve probably noticed that the page sometimes jumps a little. This is because the vertical scrollbar only is visible if the content is longer than the viewport, if no [...]]]></description>
			<content:encoded><![CDATA[<p>Here are a few CSS tricks I&#8217;ve picked up along the way.</p>
<h3>Always visible vertical scrollbar</h3>
<p>When you have a fixed width centered web site open you&#8217;ve probably noticed that the page sometimes jumps a little. This is because the vertical scrollbar only is visible if the content is longer than the viewport, if no vertical scrollbar is visible in the browser. To always have the vertical scrollbar visible you can use the CSS hack below.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">html <span style="color: #00AA00;">&#123;</span>
    overflow-y<span style="color: #00AA00;">:</span> <span style="color: #993333;">scroll</span><span style="color: #00AA00;">;</span>	
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h3>CSS reset styles</h3>
<p>To make our lives as web developers easier we have a few css reset style rules which will help make things more consistent across browsers. It started out with simply setting the padding and margin of all elements to 0 with this CSS code.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Though this caused a few problems with form elements. After a few years of using the technique above I started using a CSS reset stylesheet.</p>
<ul>
<li><a href="http://meyerweb.com/eric/tools/css/reset/">Eric Meyer&#8217;s CSS Reset</a></li>
<li><a href="http://developer.yahoo.com/yui/reset/">YUI Reset CSS</a></li>
</ul>
<h3>100% min-height</h3>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">min-height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">*</span> html <span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Internet Explorer 6 has problems understanding the min-height property. Therefor I use the star selector hack to target IE6 and set the height property (IE6 uses the height property the same way as min-height, so if the content is bigger the page will still grow, like with min-height).</p>
<p><a href="http://reference.sitepoint.com/css/min-height">More information about the min-height property</a></p>
<h3>Star selector hack</h3>
<p>Applying * html {selector here} will only target Internet Explorer 5.5 and 6. Which makes this a nice way to still use valid CSS and only target those two browsers. Like in the min-height example above.</p>
<p>More information: <a href="http://reference.sitepoint.com/css/workaroundsfilters">Workarounds and Filters</a></p>
<h3>Internet Explorer 6 double margin bug</h3>
<p>When setting the float property to either left or right and having a margin set in the same direction as the float (either margin-left or margin-right) will give IE6 users twice the margin.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This will give IE6 users a left margin of 20px. Fortunately it is easy to fix. Simply add the display property and set it to inline.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span>  
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">inline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This has no negative effect on other browsers. Also, when floating inline elements (a, span, em, etc), the element automatically becomes the same as when using display:block.</p>
<h4>More on floats</h4>
<ul>
<li><a href="http://css.maxdesign.com.au/floatutorial/">Step by Step CSS float tutorial</a></li>
<li><a href="http://reference.sitepoint.com/css/floatclear">Floating and clearing</a></li>
</ul>
<h3>hasLayout in Internet Explorer</h3>
<blockquote><p>“Layout” is an IE/Win proprietary concept that determines how elements draw and bound their content, interact with and relate to other elements, and react on and transmit application/user events.</p>
<p>This quality can be irreversibly triggered by some CSS properties. Some HTML elements have “layout” by default.</p>
<p>Microsoft developers decided that elements should be able to acquire a “property” (in an object-oriented programming sense) they referred to as hasLayout, which is set to true when this rendering concept takes effect.</p>
</blockquote>
<p>Source: <a href="http://www.satzansatz.de/cssd/onhavinglayout.html">satzansatz.de</a></p>
<p>I mostly come across this when I have no width or height applied. Like in the code below.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Overflow: hidden will clear the floats in all browsers except for in IE6. I could fix this by giving #wrapper a width or by floating it. But that is not always possible. Instead I can use the star selector and give IE6 a height of 1% to just trigger hasLayout.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #00AA00;">*</span> html <span style="color: #cc00cc;">#wrapper</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">1</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#sidebar</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#content</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">600px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h4>More information on hasLayout<br />
<h4>
<ul>
<li><a href="http://www.satzansatz.de/cssd/onhavinglayout.html">satzansatz.de</a></li>
<li><a href="http://reference.sitepoint.com/css/haslayout">The Internet Explorer hasLayout Property</a></li>
</ul>
<h3>Displaying a pointer cursor for button, label and select elements</h3>
<p>I always add this code when I start a new project.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">input<span style="color: #00AA00;">&#91;</span>type<span style="color: #00AA00;">=</span>submit<span style="color: #00AA00;">&#93;</span><span style="color: #00AA00;">,</span> button<span style="color: #00AA00;">,</span> label<span style="color: #00AA00;">,</span> select <span style="color: #00AA00;">&#123;</span> 
    <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span> 
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Just to make it easier for users to see where they can click.</p>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/" rel="bookmark" title="February 6, 2010">Guide to font sizing with CSS</a></li>
<li><a href="http://www.frederikvig.com/2009/11/flash-and-flash-video-episerver-dynamic-content/" rel="bookmark" title="November 17, 2009">Flash and Flash Video EPiServer Dynamic Content</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-5-creating-the-search-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 16, 2009">Part 5: Creating the search page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/12/part-4-creating-the-standard-page-create-an-episerver-site-from-scratch/" rel="bookmark" title="December 13, 2009">Part 4: Creating the standard page – Create an EPiServer site from scratch</a></li>
<li><a href="http://www.frederikvig.com/2009/11/better-breadcrumb-trail/" rel="bookmark" title="November 14, 2009">Better breadcrumb trail</a></li>
</ul>
<p><!-- Similar Posts took 33.137 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2009/05/css-tricks-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transparent PNGs</title>
		<link>http://www.frederikvig.com/2009/05/transparent-pngs/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=transparent-pngs</link>
		<comments>http://www.frederikvig.com/2009/05/transparent-pngs/#comments</comments>
		<pubDate>Tue, 05 May 2009 20:59:17 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[Web design]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=17</guid>
		<description><![CDATA[This is mostly for my own reference, but hopefully useful for others as well. I always forget to add a pngfix for Internet Explorer 6 when using transparent PNGs. There are a few fixes out there. 24 ways: Transparent PNGs in Internet Explorer 6 (SuperSleight) IE PNG Fix &#8211; TwinHelix DD_belatedPNG: Medicine for your IE6/PNG [...]]]></description>
			<content:encoded><![CDATA[<p>This is mostly for my own reference, but hopefully useful for others as well. I always forget to add a pngfix for Internet Explorer 6 when using transparent PNGs.<br />
There are a few fixes out there.</p>
<ul>
<li><a href="http://24ways.org/2007/supersleight-transparent-png-in-ie6">24 ways: Transparent PNGs in Internet Explorer 6 (SuperSleight)</a></li>
<li><a href="http://www.twinhelix.com/css/iepngfix/">IE PNG Fix &#8211; TwinHelix</a></li>
<li><a href="http://www.dillerdesign.com/experiment/DD_belatedPNG/">DD_belatedPNG: Medicine for your IE6/PNG headache!</a></li>
</ul>
<p>The one I&#8217;ve mostly used is SuperSleight &#8211; mostly because it is so easy to setup. You only have to download the JavaScript file and transparent gif, include it in your project, update the path to the transparent gif in the JavaScript file, and then include it inside the head section of your page with IE conditional comments.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--[if lte IE 6]&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;script type=&quot;text/javascript&quot; src=&quot;supersleight-min.js&quot;&gt;&lt;/script&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;![endif]--&gt;</span></pre></div></div>

<p>If you&#8217;re using jQuery there is also a <a href="http://allinthehead.com/retro/338/supersleight-jquery-plugin">jQuery version of SuperSleight</a>. You include it in the same way as the regular JavaScript version, though remember to add the jQuery library file before. Then you can call it like this.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Checks that the SuperSleight plugin is loaded</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">supersleight</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Here you can use regular jQuery selectors to select where you want to add SuperSleight</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">supersleight</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2010/04/backup-plan-when-loading-the-jquery-library-from-cdn/" rel="bookmark" title="April 20, 2010">Backup plan when loading the jQuery library from CDN</a></li>
<li><a href="http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/" rel="bookmark" title="February 6, 2010">Guide to font sizing with CSS</a></li>
<li><a href="http://www.frederikvig.com/2009/07/asp-net-web-forms-and-jquery-thickbox-plugin/" rel="bookmark" title="July 13, 2009">ASP.NET web forms and jQuery Thickbox plugin</a></li>
<li><a href="http://www.frederikvig.com/2009/05/css-tricks-part-1/" rel="bookmark" title="May 31, 2009">CSS tricks &#8211; part 1</a></li>
<li><a href="http://www.frederikvig.com/2009/10/font-resizing-and-printing-with-jquery/" rel="bookmark" title="October 27, 2009">Font resizing and printing with jQuery</a></li>
</ul>
<p><!-- Similar Posts took 12.617 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2009/05/transparent-pngs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->