/ Published in: Other
You'll need the latest version of [jQuery](http://www.jquery.com) and the jquery.cookie plugin([Snag it here!](http://www.stilbuero.de/2006/09/17/cookie-plugin-for-jquery/))
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // See which font size the user wants $(".text a").click(function() { switch ($(this).attr("class")) { case 'small' : setFontSize(.8); break; case 'large' : setFontSize(1.6); break; case 'default' : setFontSize(1.2); break; } return false; }); // Set the font size and set a cookie function setFontSize(size) { $("#wrap, input, textarea").animate({fontSize: size+"em"}, 500).fadeIn("slow"); createCookie(size); } // Create and read coookies // Code functions by: Peter-Paul Koch // http://www.quirksmode.org/js/cookies.html function createCookie(value) { var date = new Date(); date.setTime(date.getTime()+(30*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); document.cookie = "font_size="+value+expires+"; path=/"; } var font_size = $.cookie('font_size'); if (font_size == '0.8') { $('#wrap').css("font-size",".8em"); } if (font_size == '1.6') { $('#wrap').css("font-size","1.6em"); } if (font_size == '1.2') { $('#wrap').css("font-size","1.2em"); } }); </script>