<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.1.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Javascript - text resize with cookie</title>
	<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/</link>
	<description>My little place from infinity</description>
	<pubDate>Wed, 23 Jul 2008 18:28:39 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.3</generator>

	<item>
		<title>By: Zen Zoomie</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-62</link>
		<author>Zen Zoomie</author>
		<pubDate>Mon, 16 Jul 2007 00:52:10 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-62</guid>
					<description>Hi Nick, have you been successful in integrating this type of capability into a WordPress blog?  Any chance you could give us a demo on your next post?</description>
		<content:encoded><![CDATA[<p>Hi Nick, have you been successful in integrating this type of capability into a WordPress blog?  Any chance you could give us a demo on your next post?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: nicusor</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-63</link>
		<author>nicusor</author>
		<pubDate>Mon, 16 Jul 2007 07:06:28 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-63</guid>
					<description>Before doing that, I searched and I found that there is already such a &lt;a href="http://wordpress.org/extend/plugins/wp-chgfontsize/" target="_blank" rel="nofollow"&gt;plugin for wordpress&lt;/a&gt;. 

I looked over the code and it use cookies too. If it's not working let me know and I'll make a plugin out of mine... :)</description>
		<content:encoded><![CDATA[<p>Before doing that, I searched and I found that there is already such a <a href="http://wordpress.org/extend/plugins/wp-chgfontsize/" target="_blank" rel="nofollow">plugin for wordpress</a>. </p>
<p>I looked over the code and it use cookies too. If it&#8217;s not working let me know and I&#8217;ll make a plugin out of mine&#8230; <img src='http://nicusor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Marco</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-331</link>
		<author>Marco</author>
		<pubDate>Sat, 08 Dec 2007 13:02:44 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-331</guid>
					<description>Hey Nick,

You seem to be a pro at text-size cookies, and I was wondering if you might be able to help me out. I'm using a similar script to yours, except, it is cookieless. Is there any way you might be able to show me how to enable them?

Thanks a lot, I really appreciate your help on this- it's been driving me bananas :)

Here's the code:

var tags = new Array( 'div','td','tr','p','b','table','strong','emphasis','a','h1','h2','h3','pre','sub','sup','i','th','cp','ul','ol','li','dt','dd');
var pixelArray =  new Array('10','12','16','20','24','30','40');
var emArray =  new Array('0.7','0.9','1.0','1.5','2.0','2.5','3');
var initSize = 0;

function fontSizer(inc,unit) {
	if (!document.getElementById) 
		return;
	var size = initSize;
		size += inc;
	if (size  6 ) {
		size = 6;
}
		initSize = size;
		getBody = document.getElementsByTagName('body')[0];
	for (i = 0 ; i </description>
		<content:encoded><![CDATA[<p>Hey Nick,</p>
<p>You seem to be a pro at text-size cookies, and I was wondering if you might be able to help me out. I&#8217;m using a similar script to yours, except, it is cookieless. Is there any way you might be able to show me how to enable them?</p>
<p>Thanks a lot, I really appreciate your help on this- it&#8217;s been driving me bananas <img src='http://nicusor.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here&#8217;s the code:</p>
<p>var tags = new Array( &#8216;div&#8217;,'td&#8217;,'tr&#8217;,'p&#8217;,'b&#8217;,'table&#8217;,&#8217;strong&#8217;,'emphasis&#8217;,'a&#8217;,'h1&#8242;,&#8217;h2&#8242;,&#8217;h3&#8242;,&#8217;pre&#8217;,&#8217;sub&#8217;,&#8217;sup&#8217;,'i&#8217;,'th&#8217;,'cp&#8217;,'ul&#8217;,'ol&#8217;,'li&#8217;,'dt&#8217;,'dd&#8217;);<br />
var pixelArray =  new Array(&#8217;10&#8242;,&#8217;12&#8242;,&#8217;16&#8242;,&#8217;20&#8242;,&#8217;24&#8242;,&#8217;30&#8242;,&#8217;40&#8242;);<br />
var emArray =  new Array(&#8217;0.7&#8242;,&#8217;0.9&#8242;,&#8217;1.0&#8242;,&#8217;1.5&#8242;,&#8217;2.0&#8242;,&#8217;2.5&#8242;,&#8217;3&#8242;);<br />
var initSize = 0;</p>
<p>function fontSizer(inc,unit) {<br />
	if (!document.getElementById)<br />
		return;<br />
	var size = initSize;<br />
		size += inc;<br />
	if (size  6 ) {<br />
		size = 6;<br />
}<br />
		initSize = size;<br />
		getBody = document.getElementsByTagName(&#8217;body&#8217;)[0];<br />
	for (i = 0 ; i</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: nicusor</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-334</link>
		<author>nicusor</author>
		<pubDate>Sun, 09 Dec 2007 22:06:52 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-334</guid>
					<description>Here is the whole function:

function fontSizer(inc,unit) {
       if (!document.getElementById)
               return;
       var size = initSize;
       size += inc;
       if (size &lt; 0 ) {
               size = 0;
       }
       if (size &gt; 6 ) {
               size = 6;
       }
       initSize = size;
       getBody = document.getElementsByTagName('body')[0];
       for (i = 0 ; i &lt; tags.length ; i++ ) {
               getallTags = getBody.getElementsByTagName(tags[i]);
       for (k = 0 ; k &lt; getallTags.length ; k++)
               getallTags[k].style.fontSize = (unit=='px') ? pixelArray[size]+unit : emArray[size]+unit;
       }
}

It seems to be fine - could you give me more details about your problem?</description>
		<content:encoded><![CDATA[<p>Here is the whole function:</p>
<p>function fontSizer(inc,unit) {<br />
       if (!document.getElementById)<br />
               return;<br />
       var size = initSize;<br />
       size += inc;<br />
       if (size < 0 ) {<br />
               size = 0;<br />
       }<br />
       if (size > 6 ) {<br />
               size = 6;<br />
       }<br />
       initSize = size;<br />
       getBody = document.getElementsByTagName(&#8217;body&#8217;)[0];<br />
       for (i = 0 ; i < tags.length ; i++ ) {<br />
               getallTags = getBody.getElementsByTagName(tags[i]);<br />
       for (k = 0 ; k < getallTags.length ; k++)<br />
               getallTags[k].style.fontSize = (unit==&#8217;px&#8217;) ? pixelArray[size]+unit : emArray[size]+unit;<br />
       }<br />
}</p>
<p>It seems to be fine - could you give me more details about your problem?</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: marko</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-335</link>
		<author>marko</author>
		<pubDate>Sun, 09 Dec 2007 23:30:33 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-335</guid>
					<description>Hi Nico,

Thanks for completing my post. The problem with the aforementioned function is that it doesn't seem to create a cookie, so clicking any internal links resets the text-size. Would you know how to implement this feature? 

Thanks a ton for your help!!

Marco</description>
		<content:encoded><![CDATA[<p>Hi Nico,</p>
<p>Thanks for completing my post. The problem with the aforementioned function is that it doesn&#8217;t seem to create a cookie, so clicking any internal links resets the text-size. Would you know how to implement this feature? </p>
<p>Thanks a ton for your help!!</p>
<p>Marco</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: nicusor</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-336</link>
		<author>nicusor</author>
		<pubDate>Mon, 10 Dec 2007 07:57:20 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-336</guid>
					<description>First you need to add those 2 cookies functions: createCookie &#038; readCookie. 
Then change this line:
var initSize = 0;

to:
var cookie = readCookie("initSize");
initSize = cookie ? cookie : 0;

And finally, in the body of fontSizer function, add after:
initSize = size;

this line:
createCookie("initSize", initSize, 365);

That should do it... let me know how it works!

Cheers,
Nick</description>
		<content:encoded><![CDATA[<p>First you need to add those 2 cookies functions: createCookie &#038; readCookie.<br />
Then change this line:<br />
var initSize = 0;</p>
<p>to:<br />
var cookie = readCookie(&#8221;initSize&#8221;);<br />
initSize = cookie ? cookie : 0;</p>
<p>And finally, in the body of fontSizer function, add after:<br />
initSize = size;</p>
<p>this line:<br />
createCookie(&#8221;initSize&#8221;, initSize, 365);</p>
<p>That should do it&#8230; let me know how it works!</p>
<p>Cheers,<br />
Nick</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Marco</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-337</link>
		<author>Marco</author>
		<pubDate>Mon, 10 Dec 2007 09:46:35 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-337</guid>
					<description>I tried the code you provided me with, but it doesn't seem to work- fontSizer doesn't seem to do anything and FIreFox Error Console spits out "fontSizer not defined". :( Any ideas? Thanks a lot for your help Nick!</description>
		<content:encoded><![CDATA[<p>I tried the code you provided me with, but it doesn&#8217;t seem to work- fontSizer doesn&#8217;t seem to do anything and FIreFox Error Console spits out &#8220;fontSizer not defined&#8221;. <img src='http://nicusor.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> Any ideas? Thanks a lot for your help Nick!</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: nicusor</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-341</link>
		<author>nicusor</author>
		<pubDate>Tue, 11 Dec 2007 08:31:26 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-341</guid>
					<description>Hey Marco,

Send me the file you are using so I can spot the problem...

Cheers,
Nick</description>
		<content:encoded><![CDATA[<p>Hey Marco,</p>
<p>Send me the file you are using so I can spot the problem&#8230;</p>
<p>Cheers,<br />
Nick</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: Mike</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-555</link>
		<author>Mike</author>
		<pubDate>Tue, 18 Mar 2008 13:58:08 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-555</guid>
					<description>Sorry Nick, pls ignore my previous post. I can't get that script working on my site anyway.

What would be really cool would be a 'reset' button for your script.

Do you have the code for that?  :smile: 

Thanks again,
Mike</description>
		<content:encoded><![CDATA[<p>Sorry Nick, pls ignore my previous post. I can&#8217;t get that script working on my site anyway.</p>
<p>What would be really cool would be a &#8216;reset&#8217; button for your script.</p>
<p>Do you have the code for that?  <img src='http://nicusor.com/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' /> </p>
<p>Thanks again,<br />
Mike</p>
]]></content:encoded>
				</item>
	<item>
		<title>By: nicusor</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-556</link>
		<author>nicusor</author>
		<pubDate>Tue, 18 Mar 2008 20:33:45 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-556</guid>
					<description>Hey Mike, 

You can add another link like this:
&#60;a href="javascript:fsize(10,'px','content');" rel="nofollow"&gt;Reset&#60;/a&gt; or 
&#60;a href="#" onclick="fsize(10,'px','content');" rel="nofollow"&gt;Reset&#60;/a&gt;</description>
		<content:encoded><![CDATA[<p>Hey Mike, </p>
<p>You can add another link like this:<br />
&lt;a href=&#8221;javascript:fsize(10,&#8217;px&#8217;,'content&#8217;);&#8221; rel=&#8221;nofollow&#8221;>Reset&lt;/a> or<br />
&lt;a href=&#8221;#&#8221; onclick=&#8221;fsize(10,&#8217;px&#8217;,'content&#8217;);&#8221; rel=&#8221;nofollow&#8221;>Reset&lt;/a></p>
]]></content:encoded>
				</item>
	<item>
		<title>By: mike</title>
		<link>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-557</link>
		<author>mike</author>
		<pubDate>Wed, 19 Mar 2008 10:01:48 +0000</pubDate>
		<guid>http://nicusor.com/programming-stuff/javascript-text-resize-with-cookie/#comment-557</guid>
					<description>Great. Thanks Nick!  :smile: 

Mike</description>
		<content:encoded><![CDATA[<p>Great. Thanks Nick!  <img src='http://nicusor.com/wp-includes/images/smilies/icon_smile.gif' alt=':smile:' class='wp-smiley' /> </p>
<p>Mike</p>
]]></content:encoded>
				</item>
</channel>
</rss>
