<?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 Dec 2011 23:33:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Absolute URLs and HTTP/HTTPS</title>
		<link>http://www.frederikvig.com/2011/06/absolute-urls-and-httphttps/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=absolute-urls-and-httphttps</link>
		<comments>http://www.frederikvig.com/2011/06/absolute-urls-and-httphttps/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 18:52:28 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[Web design]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1602</guid>
		<description><![CDATA[Here&#8217;s a neat little trick I saw after browsing the HTML 5 Boilerplate code. Instead of specifying a protocol (HTTP/HTTPS) when adding absolute URLs to resources like jQuery on Google CDN you only need to specify // followed by the rest of the URL. The browser will then automatically use the correct one based on ...]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a neat little trick I saw after browsing the <a href="http://html5boilerplate.com/">HTML 5 Boilerplate code</a>. Instead of specifying a protocol (HTTP/HTTPS) when adding absolute URLs to resources like jQuery on Google CDN you only need to specify // followed by the rest of the URL. The browser will then automatically use the correct one based on the protocol of the site the user is on right now. Note that this only works if both the HTTP and the HTTPS version of the URL exists.</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;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre>
</div>
</div>
<p>Can be written 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;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre>
</div>
</div>
<p>If I had this code on https://www.frederikvig.com, the browser would send a request to the URL: https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js.<strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2010/04/detecting-ajax-requests-on-the-server/" rel="bookmark" title="April 6, 2010">Detecting Ajax requests on the server</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>
<li><a href="http://www.frederikvig.com/2010/11/removing-http-headers-for-asp-net-sites/" rel="bookmark" title="November 26, 2010">Removing HTTP Headers for ASP.NET sites</a></li>
<li><a href="http://www.frederikvig.com/2010/05/creating-a-contact-form-with-asp-net-mvc/" rel="bookmark" title="May 13, 2010">Creating a contact form with ASP.NET MVC</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>
</ul>
<p><!-- Similar Posts took 10.188 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/06/absolute-urls-and-httphttps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Links for EPiServer Developers &#8211; #2</title>
		<link>http://www.frederikvig.com/2011/03/links-for-episerver-developers-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=links-for-episerver-developers-2</link>
		<comments>http://www.frederikvig.com/2011/03/links-for-episerver-developers-2/#comments</comments>
		<pubDate>Sat, 12 Mar 2011 12:47:30 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1504</guid>
		<description><![CDATA[If you have any link suggestions please email me at: frederikvig@hotmail.com. Security web.config Security Analyzer &#8211; onlien and offline tool for checking your sites web.config for security vulnerabilities ASP.NET Create PDF document using iTextSharp in ASP.Net 4.0 and MemoryMappedFile RazorEngine &#8211; use the powerful Razor template engine in your project. I&#8217;ve used this for newsletter ...]]></description>
			<content:encoded><![CDATA[<p>If you have any link suggestions please email me at: <a href="mailto:frederikvig@hotmail.com">frederikvig@hotmail.com</a>.</p>
<h3>Security</h3>
<ul>
<li><a href="http://www.wcanalyzer.com/">web.config Security Analyzer</a> &#8211; onlien and offline tool for checking your sites web.config for security vulnerabilities</li>
</ul>
<h3>ASP.NET</h3>
<ul>
<li><a href="http://weblogs.asp.net/sreejukg/archive/2011/03/07/create-pdf-document-using-itextsharp-in-asp-net-4-0-and-memorymappedfile.aspx">Create PDF document using iTextSharp in ASP.Net 4.0 and MemoryMappedFile</a></li>
<li><a href="http://razorengine.codeplex.com/">RazorEngine</a> &#8211; use the powerful Razor template engine in your project. I&#8217;ve used this for newsletter templates with great success.</li>
</ul>
<h3>Performance</h3>
<ul>
<li><a href="http://aspnet.codeplex.com/releases/view/61896">ASP.NET Sprite and Image Optimization</a> &#8211; Easily generate CSS sprites. Works for both ASP.NET Webforms and MVC</li>
<li><a href="http://isis.codeplex.com/">Isis</a> &#8211; great new tool for cache management</li>
</ul>
<h3>Tools</h3>
<ul>
<li><a href="https://addons.mozilla.org/en-US/firefox/addon/user-agent-switcher/">User Agent-Switcher addon for Firefox</a> &#8211; great for when developing for Mobile devices or just seeing what Google sees when it indexes your site</li>
</ul>
<h3>EPiServer</h3>
<ul>
<li><a href="https://www.coderesort.com/p/epicode/wiki/Extensions">EPiCode Extensions</a> &#8211; over 80 extension methods for EPiServer</li>
<li><a href="http://world.episerver.com/Blogs/David-Knipe/Dates/2010/5/Customising-the-EPiServer-UI/">Customising the EPiServer UI</a> &#8211; nice post by David Knipe that shows how powerful EPiServer&#8217;s customization and plugin system is</li>
<li><a href="http://world.episerver.com/Blogs/Lee-Crowe/Dates/2011/3/ElencySolutionsMultipleProperty-v11-Released/">ElencySolutions.MultipleProperty v1.1 Released</a></li>
<li><a href="http://world.episerver.com/Blogs/Jonas-Bergqvist/Dates/2011/2/Generic-Find-method-in-Dynamic-data-store/">Typed “Find” method in Dynamic data store</a></li>
<li><a href="http://joelabrahamsson.com/entry/getting-started-with-episerver-cms-development">Getting started with EPiServer CMS development</a> &#8211; great post by Joel Abrahamsson for new developers to EPiServer</li>
<li><a href="http://blog.fredrikhaglund.se/blog/2011/03/22/new-stuff-in-episerver-cms-6-r2/">New stuff in EPiServer CMS 6 R2</a> &#8211; nice overview by Fredrik Haglund</li>
<li><a href="http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2011/3/Container-pages/">Container pages</a> &#8211; new type of page in EPiServer CMS 6 R2</li>
<li><a href="http://world.episerver.com/Blogs/Linus-Ekstrom/Dates/2011/3/Changes-to-the-EPiServer-CMS-Globalization/">Changes to the EPiServer CMS Globalization</a></li>
<li><a href="http://world.episerver.com/Blogs/David-Knipe/Dates/2010/9/Checklist-for-setting-up-Windows-Authentication-in-EPiServer-on-a-development-machine/">Checklist for setting up Windows Authentication in EPiServer on a development machine</a></li>
<li><a href="http://world.episerver.com/Articles/Items/Relate-Intranet-Demo-Site/">Relate Intranet Demo Site </a> &#8211; Demo templates for a social intranet</li>
</ul>
<h3>Videos</h3>
<ul>
<li><a href="http://stevesmithblog.com/blog/asp-net-tips-and-tricks-on-dnrtv/">ASP.NET Tips and Tricks on dnrTV</a> &#8211; Steve Smith goes through a lot in this video, from tracing and caching to performance optimizing ASP.NET MVC 3 applications</li>
</ul>
<h3>HTML, CSS, JavaScript</h3>
<ul>
<li><a href="http://www.smashingmagazine.com/2011/03/11/syncing-content-with-html5-video/">Syncing Content With HTML5 Video</a> &#8211; excellent article that gives you a taste for what is possible with HTML5 Video and interactions on your web page (interacting with Google Maps or similar at certain points in the video for instance)</li>
<li><a href="http://popcornjs.org/">Popcorn.js</a> &#8211; HTML5 Video event Framework, with a lot of plugins for Google Maps, Wikipedia, Flickr etc</li>
<li><a href="http://butterapp.org/">Butter</a> &#8211; Popcorn.js authoring tool</li>
<li><a href="http://www.456bereastreet.com/archive/201103/flexible_height_vertical_centering_with_css_beyond_ie7/">Flexible height vertical centering with CSS, beyond IE7</a></li>
<li><a href="http://html5boilerplate.com/">HTML5 Boilerplate</a> &#8211; great start for new projects</li>
<li><a href="https://github.com/paulirish/html5-boilerplate-server-configs/blob/master/web.config">Web.config for HTML5 Boilerplate</a></li>
<li><a href="http://msdn.microsoft.com/en-us/ie/ff468705.aspx">Internet Explorer 9 Guide for Developers</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/cc351024">CSS Compatibility and Internet Explorer</a></li>
<li><a href="http://www.pluginquery.com/">Search for jQuery plugins</a> &#8211; search engine that&#8217;ll help you find jQuery plugins</li>
<li><a href="http://bonsaiden.github.com/JavaScript-Garden/">JavaScript Garden</a> &#8211; JavaScript Garden is a growing collection of documentation about the most quirky parts of the JavaScript programming language.</li>
</ul>
<h3>Mobile</h3>
<ul>
<li><a href="http://51degrees.codeplex.com/">51 Degrees Mobile Device Detection and Redirection</a> &#8211; Based on the <a href="http://wurfl.sourceforge.net/">WURFL project</a>. Setup rules for mobile devices visiting your site</li>
</ul>
<h3>Web</h3>
<ul>
<li><a href="http://programmers.stackexchange.com/questions/46716/what-should-a-developer-know-before-building-a-public-web-site">What should a developer know before building a public web site?</a></li>
</ul>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2011/02/links-for-episerver-developers-1/" rel="bookmark" title="February 9, 2011">Links for EPiServer Developers &#8211; #1</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>
<li><a href="http://www.frederikvig.com/2009/10/creating-a-mobile-version-of-a-web-site/" rel="bookmark" title="October 4, 2009">Creating a mobile version of a web site</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/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>
</ul>
<p><!-- Similar Posts took 8.947 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/03/links-for-episerver-developers-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Links for EPiServer Developers &#8211; #1</title>
		<link>http://www.frederikvig.com/2011/02/links-for-episerver-developers-1/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=links-for-episerver-developers-1</link>
		<comments>http://www.frederikvig.com/2011/02/links-for-episerver-developers-1/#comments</comments>
		<pubDate>Wed, 09 Feb 2011 16:18:20 +0000</pubDate>
		<dc:creator>Frederik Vig</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[Web design]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Links]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.frederikvig.com/?p=1489</guid>
		<description><![CDATA[First post in a new series where I&#8217;ll post a list of links to useful resources for EPiServer developers. If you have any link suggestions please email me at: frederikvig@hotmail.com. Security Web Application Configuration Security Revisited &#8211; useful security checklist to go through before launching new sites (or existing) JavaScript Captcha &#8211; good post that ...]]></description>
			<content:encoded><![CDATA[<p>First post in a new series where I&#8217;ll post a list of links to useful resources for EPiServer developers. If you have any link suggestions please email me at: <a href="mailto:frederikvig@hotmail.com">frederikvig@hotmail.com</a>.</p>
<h3>Security</h3>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/magazine/gg309184.aspx">Web Application Configuration Security Revisited</a> &#8211; useful security checklist to go through before launching new sites (or existing)</li>
<li><a href="http://gatekiller.co.uk/Post/JavaScript_Captcha">JavaScript Captcha</a> &#8211; good post that discusses the problems with todays approach to securing against spam bots, and that suggest another approach using JavaScript and timing instead.</li>
</ul>
<h3>Deployment</h3>
<ul>
<li><a href="http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity.html">You&#8217;re deploying it wrong! TeamCity, Subversion &amp; Web Deploy part 1: Config transforms</a></li>
<li><a href="http://www.troyhunt.com/2011/02/automated-database-releases-with.html">Automated database releases with TeamCity and Red Gate</a></li>
</ul>
<h3>Performance</h3>
<ul>
<li><a href="http://yahoo.github.com/boomerang/doc/">Boomerang</a> &#8211; JavaScript library developed by Yahoo! for measuring the performance of a website from a client (end user&#8217;s) point of view. Along with <a href="http://developer.yahoo.com/yslow/">YSlow</a> (also from Yahoo!) and <a href="http://code.google.com/speed/page-speed/">Page Speed</a> this is a very useful tool to have.</li>
<li><a href="http://geekswithblogs.net/BlackRabbitCoder/archive/2011/02/03/c.net-little-wonders-the-useful-but-overlooked-sets.aspx">C#/.NET Little Wonders: The Useful But Overlooked Sets</a> &#8211; good post that explains Sets collections (and their changes in .NET 4) and when to use them.</li>
<li><a href="http://world.episerver.com/Blogs/Johan-Bjornfot/Dates1/2011/1/Performance-improvements-in-CMS6R2/">Performance improvements in EPiServer CMS6R2</a></li>
</ul>
<h3>Tools</h3>
<ul>
<li><a href="http://nuget.org/">NuGet</a> &#8211; very useful tool developed by Microsoft and the community for easily adding open source modules to your project. Mark Everard wrote a <a href="http://www.markeverard.com/blog/2010/11/04/using-nuget-for-episerver-third-party-libraries/">nice post</a> where he goes through adding <a href="http://pagetypebuilder.codeplex.com">Page Type Builder</a> as a NuGet package (anyone up for creating an EPiServer NuGet feed? <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</li>
<li><a href="http://weblogs.asp.net/scottgu/archive/2011/01/20/microsoft-web-farm-framework-2-0.aspx">Microsoft Web Farm Framework 2.0</a></li>
<li><a href="http://www.iis.net/download/webdeploy">Web Deploy 2.0</a></li>
</ul>
<h3>EPiServer</h3>
<ul>
<li><a href="http://world.episerver.com/Blogs/Anders-Hattestad/Dates/2011/1/Dynamic-Data-Store-and-new-properties-on-Types/">Dynamic Data Store and new properties on Types</a> &#8211; very useful extension method by Anders Hattestad for the dynamic data store. Remapping is something that most get wrong the first time they work with DDS.</li>
<li><a href="http://antecknat.se/blog/2009/11/02/creating-classes-for-pagetypebuilder-in-an-existing-project/">Creating classes for PageTypeBuilder in an existing project</a> &#8211; just because it is so awesome and alot of people don&#8217;t know about it <img src='http://www.frederikvig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</li>
<li><a href="http://world.episerver.com/Blogs/Lee-Crowe/Dates/2011/2/FilteredPageReference-v11-Released/">FilteredPageReference v1.1 Released</a></li>
<li><a href="http://world.episerver.com/Blogs/Alexander-Haneng/Dates/2011/1/Starting-a-CMS-6-sites-faster-after-build/">Starting CMS 6 sites faster after build</a> &#8211; very useful tips &#8211; especially when working with EPiServer Community</li>
<li><a href="http://www.markeverard.com/blog/2010/09/29/developing-a-custom-workflow-in-episerver-part-one/">Developing a custom workflow in EPiServer</a> &#8211; nice 4 part series on how to develop workflows for EPiServer</li>
</ul>
<h3>Code</h3>
<ul>
<li><a href="http://dotnetslackers.com/articles/aspnet/5-Helpful-DateTime-Extension-Methods.aspx">5 Helpful DateTime Extension Methods</a></li>
</ul>
<h3>Database</h3>
<ul>
<li><a href="http://www.troyhunt.com/2011/02/unnecessary-evil-of-shared-development.html">The unnecessary evil of the shared development database</a></li>
</ul>
<h3>HTML, CSS, JavaScript</h3>
<ul>
<li><a href="http://stephenwalther.com/blog/archive/2011/01/12/asp-net-and-html5-local-storage.aspx">ASP.NET and HTML5 Local Storage</a> &#8211; HTML local storage is one of the coolest new features of HTML 5. Here you&#8217;ll get a nice introduction and how to use it in your ASP.NET application.</li>
<li><a href="http://addyosmani.com/blog/large-scale-jquery/">Building Large-Scale jQuery Applications</a> &#8211; When you start using jQuery and JavaScript in larger scale your code can become very messy after a while. This post has some nice pointers on structuring your code, testing and other goodies.</li>
</ul>
<h3>ReSharper</h3>
<ul>
<li><a href="http://codebetter.com/jameskovacs/2011/01/31/easier-debugging-with-resharper-and-the-clipboard/">Easier Debugging with ReSharper and the Clipboard</a></li>
</ul>
<p><strong>Related Posts:</strong>
<ul class="similar-posts">
<li><a href="http://www.frederikvig.com/2011/03/links-for-episerver-developers-2/" rel="bookmark" title="March 12, 2011">Links for EPiServer Developers &#8211; #2</a></li>
<li><a href="http://www.frederikvig.com/2011/05/introduction-owasp-top-10-for-episerver-developers/" rel="bookmark" title="May 6, 2011">Introduction &#8211; OWASP Top 10 for EPiServer Developers</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/2011/06/episerver-mail-5-r2-the-stored-procedure-spepiservermailsamplerecipientsourcegetmailinglists-doesnt-exist/" rel="bookmark" title="June 2, 2011">EPiServer Mail 5 R2: The stored procedure &#8216;spEPiServerMailSampleRecipientSourceGetMailingLists&#8217; doesn&#8217;t exist</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 9.036 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2011/02/links-for-episerver-developers-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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&#038;utm_medium=rss&#038;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;">100%</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/2011/05/css3-buttons-and-episerver-editor-stylesheet/" rel="bookmark" title="May 8, 2011">CSS3 buttons and EPiServer editor stylesheet</a></li>
</ul>
<p><!-- Similar Posts took 14.761 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.frederikvig.com/2010/02/guide-to-font-sizing-with-css/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Better breadcrumb trail</title>
		<link>http://www.frederikvig.com/2009/11/better-breadcrumb-trail/?utm_source=rss&#038;utm_medium=rss&#038;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; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">EPiServer.Core</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Text</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> EPiServer<span style="color: #008000;">.</span><span style="color: #0000FF;">Templates</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Public</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Units</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Static</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">partial</span> <span style="color: #6666cc; font-weight: bold;">class</span> BreadCrumbs <span style="color: #008000;">:</span> UserControlBase
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #0600FF; font-weight: bold;">const</span> <span style="color: #6666cc; font-weight: bold;">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; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">int</span> _maxLength <span style="color: #008000;">=</span> <span style="color: #FF0000;">60</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">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; font-weight: bold;">protected</span> <span style="color: #0600FF; font-weight: bold;">override</span> <span style="color: #6666cc; font-weight: bold;">void</span> OnPreRender<span style="color: #008000;">&#40;</span>EventArgs e<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Breadcrumbs<span style="color: #008000;">.</span><span style="color: #0000FF;">Text</span> <span style="color: #008000;">=</span> GenerateBreadCrumbs<span style="color: #008000;">&#40;</span>CurrentPage<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> GenerateBreadCrumbs<span style="color: #008000;">&#40;</span>PageData page<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#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: #008000;">&#40;</span><span style="color: #FF0000;">8</span> <span style="color: #008000;">*</span> MaxLength<span style="color: #008000;">&#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: #6666cc; font-weight: bold;">int</span> breadCrumbsLength <span style="color: #008000;">=</span> Translate<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;/navigation/startpage&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>page <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">!</span>page<span style="color: #008000;">.</span><span style="color: #0000FF;">PageLink</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CompareToIgnoreWorkID</span><span style="color: #008000;">&#40;</span>PageReference<span style="color: #008000;">.</span><span style="color: #0000FF;">StartPage</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                breadCrumbsLength <span style="color: #008000;">+=</span> page<span style="color: #008000;">.</span><span style="color: #0000FF;">PageName</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>breadCrumbsLength <span style="color: #008000;">&gt;</span> MaxLength<span style="color: #008000;">&#41;</span>
                <span style="color: #008000;">&#123;</span>
                    breadCrumbsText<span style="color: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #666666;">&quot;...&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
                    <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
                <span style="color: #008000;">&#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: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetLink</span><span style="color: #008000;">&#40;</span>page<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#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; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetParentPageData</span><span style="color: #008000;">&#40;</span>page<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// Generate the start page link </span>
            <span style="color: #6666cc; font-weight: bold;">string</span> startPageLinkUrl <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Empty</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">IsNullOrEmpty</span><span style="color: #008000;">&#40;</span>startPageLinkUrl<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                startPageLinkUrl <span style="color: #008000;">=</span> Server<span style="color: #008000;">.</span><span style="color: #0000FF;">UrlPathEncode</span><span style="color: #008000;">&#40;</span>GetPage<span style="color: #008000;">&#40;</span>PageReference<span style="color: #008000;">.</span><span style="color: #0000FF;">StartPage</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">LinkURL</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #6666cc; font-weight: bold;">string</span> startPageLink <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span>_link, startPageLinkUrl, Translate<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;/navigation/startpage&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            breadCrumbsText<span style="color: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, startPageLink<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #6666cc; font-weight: bold;">string</span> listStart <span style="color: #008000;">=</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#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: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            breadCrumbsText<span style="color: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span>, listStart<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            breadCrumbsText<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;&lt;/ol&gt;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> breadCrumbsText<span style="color: #008000;">.</span><span style="color: #0000FF;">ToString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#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; font-weight: bold;">private</span> PageData GetParentPageData<span style="color: #008000;">&#40;</span>PageData pageData<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#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; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>pageData <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">||</span> pageData<span style="color: #008000;">.</span><span style="color: #0000FF;">ParentLink</span> <span style="color: #008000;">==</span> PageReference<span style="color: #008000;">.</span><span style="color: #0000FF;">StartPage</span> <span style="color: #008000;">||</span> pageData<span style="color: #008000;">.</span><span style="color: #0000FF;">ParentLink</span> <span style="color: #008000;">==</span> PageReference<span style="color: #008000;">.</span><span style="color: #0000FF;">RootPage</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#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: #008000;">&#40;</span>pageData<span style="color: #008000;">.</span><span style="color: #0000FF;">ParentLink</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>pageData <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> pageData<span style="color: #008000;">.</span><span style="color: #0000FF;">VisibleInMenu</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> pageData<span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
            <span style="color: #008080; font-style: italic;">// Step up to next parent</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> GetParentPageData<span style="color: #008000;">&#40;</span>pageData<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#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; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> GetLink<span style="color: #008000;">&#40;</span>PageData page<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #6666cc; font-weight: bold;">string</span> pageName <span style="color: #008000;">=</span> page<span style="color: #008000;">.</span><span style="color: #0000FF;">Property</span><span style="color: #008000;">&#91;</span><span style="color: #666666;">&quot;PageName&quot;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">ToWebString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>page<span style="color: #008000;">.</span><span style="color: #0000FF;">PageLink</span><span style="color: #008000;">.</span><span style="color: #0000FF;">CompareToIgnoreWorkID</span><span style="color: #008000;">&#40;</span>CurrentPage<span style="color: #008000;">.</span><span style="color: #0000FF;">PageLink</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#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: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span>_link, Server<span style="color: #008000;">.</span><span style="color: #0000FF;">UrlPathEncode</span><span style="color: #008000;">&#40;</span>page<span style="color: #008000;">.</span><span style="color: #0000FF;">LinkURL</span><span style="color: #008000;">&#41;</span>, pageName<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#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; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> MaxLength
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> _maxLength<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> _maxLength <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> BreadcrumbId
        <span style="color: #008000;">&#123;</span>
            get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> _breadcrumbId<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
            set <span style="color: #008000;">&#123;</span> _breadcrumbId <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#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/07/episerver-web-controls-property/" rel="bookmark" title="July 5, 2009">EPiServer web controls: Property</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/05/episerver-link-collection/" rel="bookmark" title="May 18, 2009">EPiServer Link Collection Property</a></li>
</ul>
<p><!-- Similar Posts took 18.711 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&#038;utm_medium=rss&#038;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;">80%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body.<span style="color: #993333;">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;">120%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body.<span style="color: #993333;">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;">140%</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/2010/10/avoiding-conflicts-when-using-jquery-and-episerver-composer/" rel="bookmark" title="October 25, 2010">Avoiding conflicts when using jQuery and EPiServer Composer</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/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/measuring-javascript-performance/" rel="bookmark" title="May 10, 2009">Measuring JavaScript performance</a></li>
<li><a href="http://www.frederikvig.com/2009/05/transparent-pngs/" rel="bookmark" title="May 5, 2009">Transparent PNGs</a></li>
</ul>
<p><!-- Similar Posts took 34.224 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&#038;utm_medium=rss&#038;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://51degrees.codeplex.com/">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/2011/03/links-for-episerver-developers-2/" rel="bookmark" title="March 12, 2011">Links for EPiServer Developers &#8211; #2</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/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/2010/11/programmatically-adding-files-to-episerver/" rel="bookmark" title="November 23, 2010">Programmatically adding files to EPiServer&#8217;s File System</a></li>
</ul>
<p><!-- Similar Posts took 23.500 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&#038;utm_medium=rss&#038;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[Code Snippet]]></category>
		<category><![CDATA[CSS]]></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;">1%</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/2011/03/links-for-episerver-developers-2/" rel="bookmark" title="March 12, 2011">Links for EPiServer Developers &#8211; #2</a></li>
</ul>
<p><!-- Similar Posts took 25.719 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&#038;utm_medium=rss&#038;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/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/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/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/2011/08/easily-add-comment-functionality-to-episerver-cms-with-disqus/" rel="bookmark" title="August 21, 2011">Easily add comment functionality to EPiServer CMS with DISQUS</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>
</ul>
<p><!-- Similar Posts took 25.512 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! -->
