<?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>~ overflow ~ &#187; js</title>
	<atom:link href="http://www.overflow.biz/blog/lang/en-us/tag/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.overflow.biz/blog</link>
	<description>Coding and Internet Randomness</description>
	<lastBuildDate>Sun, 08 Jan 2012 23:34:17 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en-us</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Javascript ParseInt Vs. ParseFloat</title>
		<link>http://www.overflow.biz/blog/lang/en-us/2010/05/01/javascript-parseint-vs-parsefloat?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=javascript-parseint-vs-parsefloat</link>
		<comments>http://www.overflow.biz/blog/lang/en-us/2010/05/01/javascript-parseint-vs-parsefloat#comments</comments>
		<pubDate>Sat, 01 May 2010 21:02:39 +0000</pubDate>
		<dc:creator>z3n</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[parseFloat]]></category>
		<category><![CDATA[parseInt]]></category>

		<guid isPermaLink="false">http://www.overflow.biz/blog/?p=412</guid>
		<description><![CDATA[Problem:
While debbuging an javascript application i found out a wrong calculation result.
Solution:
Apparently javascript been developed my microsoft, due the extensive issues with many misbehaviors it&#8217;s quite sad to find out that there&#8217;s no way to escape from them.

var test=&#34;08&#34;;

alert(parseInt(test)+1); // will return 1
alert(parseFloat(test)+1); // will return 9, as supposed to

]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>While debbuging an javascript application i found out a wrong calculation result.</p>
<p><strong>Solution:</strong></p>
<p>Apparently javascript been developed my microsoft, due the extensive issues with many misbehaviors it&#8217;s quite sad to find out that there&#8217;s no way to escape from them.</p>
<pre class="brush: jscript;">
var test=&#34;08&#34;;

alert(parseInt(test)+1); // will return 1
alert(parseFloat(test)+1); // will return 9, as supposed to
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.overflow.biz/blog/lang/en-us/2010/05/01/javascript-parseint-vs-parsefloat/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Floating Point Issues</title>
		<link>http://www.overflow.biz/blog/lang/en-us/2010/04/01/javascript-floating-point-issues?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=javascript-floating-point-issues</link>
		<comments>http://www.overflow.biz/blog/lang/en-us/2010/04/01/javascript-floating-point-issues#comments</comments>
		<pubDate>Thu, 01 Apr 2010 05:23:07 +0000</pubDate>
		<dc:creator>z3n</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[floating point]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[round]]></category>

		<guid isPermaLink="false">http://www.overflow.biz/blog/?p=370</guid>
		<description><![CDATA[Problem:
Javascript floating point issues.
Solution:
It&#8217;s well known that javascript has major issues when it comes to precision math, even the simplest operations tend to be a nightmare. Although i was aware of that i suddenly found myself into another tricky thing with zeros on the left (eg: 025).
To avoid issues with javascript rounding issues I get [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>Javascript floating point issues.</p>
<p><strong>Solution:</strong></p>
<p>It&#8217;s well known that javascript has major issues when it comes to precision math, even the simplest operations tend to be a nightmare. Although i was aware of that i suddenly found myself into another tricky thing with zeros on the left (eg: 025).</p>
<p>To avoid issues with javascript rounding issues I get all numbers converted to strings, stripping their floating point, this only works if all numbers are from the same precision or if you do a function do that, since there&#8217;s no rounding function (besides .toFixed) that does that proprietly.</p>
<p>So, in sum, 1.23 will be calculated as 123, eg:</p>
<pre class="brush: jscript;">
var a = 1.23;
var b = 4.56;
a = parseInt(a.toString().replace(/\./g,&#34;&#34;)); // 1.23 -&#62; 123
b = parseInt(b.toString().replace(/\./g,&#34;&#34;)); // 4.56 -&#62; 4.56
var x = a + b; // = 579
x=x.toString();
return x.substr(0,x.length-2)+&#34;.&#34;+x.substr(x.length-2);
</pre>
<p>Now that&#8217;s good, right&#8230;?? Apparently yes, but let&#8217;s do another example:</p>
<pre class="brush: jscript;">
var a= 0.25;
a = parseInt(a.toString().replace(/\./g,&#34;&#34;)); // 0.25 -&#62; 025
var x = 1*a; // 1* 025 = 025  -- right? js will return 021
return x.substr(0,x.length-2)+&#34;.&#34;+x.substr(x.length-2);
</pre>
<p>When there&#8217;s a zero on the left, javascript goes nuts. An easy fix would be:</p>
<pre class="brush: jscript;">
while (x.toString().substr(0,1) == &#34;0&#34;)
    x=x.substr(1);
</pre>
<p>and problem solved!</p>
<p><strong>References:</strong></p>
<p><a href="http://www.w3schools.com/jsref/jsref_tofixed.asp" target="_blank">w3Schools</a></p>
<p><a href="http://www.webmasterworld.com/javascript/3030448.htm" target="_blank">webmasterworld</a></p>
<p><a href="http://www.jibbering.com/faq/faq_notes/type_convert.html" target="_blank">jibbering</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.overflow.biz/blog/lang/en-us/2010/04/01/javascript-floating-point-issues/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling a Javascript function from a different frame</title>
		<link>http://www.overflow.biz/blog/lang/en-us/2009/06/09/calling-a-javascript-function-from-a-different-frame?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=calling-a-javascript-function-from-a-different-frame</link>
		<comments>http://www.overflow.biz/blog/lang/en-us/2009/06/09/calling-a-javascript-function-from-a-different-frame#comments</comments>
		<pubDate>Tue, 09 Jun 2009 14:49:32 +0000</pubDate>
		<dc:creator>z3n</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[frame]]></category>
		<category><![CDATA[functios]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://overflow.biz/blog/?p=141</guid>
		<description><![CDATA[Problem:
How to call a function from a different frame/iframe ?
Solution:
It depends where the function is, when it&#8217;s on the main frame, or if you&#8217;re calling a funcion that&#8217;s on _top from inside a iframe:
top.function();
If you&#8217;re calling a function from a frame to another:
parent.frames['frame_name'].function();
or
parent.frames[frame_number].function();









]]></description>
			<content:encoded><![CDATA[<p><span lang="en-us"><strong>Problem:</strong></span></p>
<p><span lang="en-us">How to call a function from a different frame/iframe ?</span></p>
<p><span lang="en-us"><strong>Solution:</strong></span></p>
<p><span lang="en-us">It depends where the function is, when it&#8217;s on the main frame, or if you&#8217;re calling a funcion that&#8217;s on _top from inside a iframe:</span></p>
<p><span lang="en-us"><em>top.<strong>function()</strong>;</em></span></p>
<p><span lang="en-us">If you&#8217;re calling a function from a frame to another:</span></p>
<p><span lang="en-us"><em>parent.frames['frame_name'].<strong>function()</strong>;</em></span></p>
<p><span lang="en-us">or</span></p>
<p><span lang="en-us"><em>parent.frames[frame_number].<strong>function()</strong>;</em></span></p>









]]></content:encoded>
			<wfw:commentRss>http://www.overflow.biz/blog/lang/en-us/2009/06/09/calling-a-javascript-function-from-a-different-frame/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript to get the whole document width and height</title>
		<link>http://www.overflow.biz/blog/lang/en-us/2009/05/25/javascript-to-get-the-whole-document-width-and-height?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=javascript-to-get-the-whole-document-width-and-height</link>
		<comments>http://www.overflow.biz/blog/lang/en-us/2009/05/25/javascript-to-get-the-whole-document-width-and-height#comments</comments>
		<pubDate>Mon, 25 May 2009 23:56:42 +0000</pubDate>
		<dc:creator>z3n</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[full height]]></category>
		<category><![CDATA[full width]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://overflow.biz/blog/?p=118</guid>
		<description><![CDATA[Problem:
How to get document&#8217;s height and width, not only the view area or the window size, but the whole thing including the scrolling.
Solution:
There are some variants of this solution, because some browsers take this proprieties in a different way, however, here&#8217;s a little function i wrote able to return the right dimensions no matter what:
with [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>How to get document&#8217;s height and width, not only the view area or the window size, but the whole thing including the scrolling.</p>
<p><strong>Solution:</strong></p>
<p>There are some variants of this solution, because some browsers take this proprieties in a different way, however, here&#8217;s a little function i wrote able to return the right dimensions no matter what:</p>
<blockquote><p><em>with (document.documentElement) {</em></p>
<p><em> var h=Math.max(clientHeight,scrollHeight);</em></p>
<p><em> var w=Math.max(clientWidth,scrollWidth);</em></p>
<p><em>}</em></p></blockquote>
<p>there&#8217;s also the inner values, but they only work on certain browsers, this would be able to get the numbers you need on <em>IE6+</em> , <em>FF</em> and mostly of the decent browsers, if you must have working on every browser check quirksmode. This will also return the highest value, meaning that if the page itself won&#8217;t fill client&#8217;s width/height, it will get the biggest value, perfect when you need to do a full page div or something like that.</p>
<p><strong>Sources:</strong></p>
<p><a href="http://www.howtocreate.co.uk/tutorials/javascript/browserwindow" target="_blank">howtocreate.co.uk</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.overflow.biz/blog/lang/en-us/2009/05/25/javascript-to-get-the-whole-document-width-and-height/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple AJAX/xmlhttp query issue</title>
		<link>http://www.overflow.biz/blog/lang/en-us/2009/05/20/simple-ajax-query-issue?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=simple-ajax-query-issue</link>
		<comments>http://www.overflow.biz/blog/lang/en-us/2009/05/20/simple-ajax-query-issue#comments</comments>
		<pubDate>Wed, 20 May 2009 20:56:17 +0000</pubDate>
		<dc:creator>z3n</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[alternate]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[script.aculo.us]]></category>
		<category><![CDATA[xmlhttp]]></category>

		<guid isPermaLink="false">http://overflow.biz/blog/?p=112</guid>
		<description><![CDATA[Problem:
You like jQuery, however, doing simple tasks get impossible since jQuery is too massive, even packed it&#8217;s over 50kb. The alternate, script.taculo.us, is even bigger!
Solution:
Doing a simple ajax or xmlhttp request, is nothing out of this world, actually, it&#8217;s pretty easy, you just need to watch it if you do more than one on the [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>You like <a href="http://www.jquery.com" target="_blank">jQuery</a>, however, doing simple tasks get impossible since jQuery is too massive, even packed it&#8217;s over 50kb. The alternate, <a href="http://script.taculo.us/" target="_blank">script.taculo.us</a>, is even bigger!</p>
<p><strong>Solution:</strong></p>
<p>Doing a simple ajax or xmlhttp request, is nothing out of this world, actually, it&#8217;s pretty easy, you just need to watch it if you do more than one on the same page, or when a error happen you might want to have a handler.</p>
<p>Based on <a href="http://www.quirksmode.org/" target="_blank">quirks mode</a> example i wrote this little function, it&#8217;s able to do a rudimentar queue and return plain text from a remote server, it&#8217;s also compatible with IE.</p>
<div class="geshi no javascript">
<div class="head">var x=null;var p=0; // p is the processing control, while the request is running it will be true, if another request shows up it will fall into a timer loop until the first one ends</div>
<ol>
<li class="li1">
<div class="de1">_lD=<span class="kw2">function</span><span class="br0">&#40;</span>url<span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160;<span class="kw1">if</span><span class="br0">&#40;</span>p==<span class="nu0">1</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; setTimeout<span class="br0">&#40;</span><span class="st0">&#34;_lD(&#39;&#34;</span>+url+<span class="st0">&#34;&#39;)&#34;</span>,<span class="nu0">250</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160;<span class="br0">&#125;</span><span class="kw1">else</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; p=<span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; x=<span class="kw2">null</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; <span class="kw1">if</span><span class="br0">&#40;</span>window.<span class="me1">XMLHttpRequest</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160;x=<span class="kw2">new</span> XMLHttpRequest<span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; <span class="br0">&#125;</span><span class="kw1">else</span> <span class="kw1">if</span><span class="br0">&#40;</span>window.<span class="me1">ActiveXObject</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160;x=<span class="kw2">new</span> ActiveXObject<span class="br0">&#40;</span><span class="st0">&#34;Microsoft.XMLHTTP&#34;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; <span class="kw1">if</span><span class="br0">&#40;</span>x<span class="sy0">!</span>=<span class="kw2">null</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160;x.<span class="me1">onreadystatechange</span>=<span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160;<span class="kw2">var</span> r=<span class="st0">&#34;&#34;</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160;<span class="kw1">if</span><span class="br0">&#40;</span>x.<span class="me1">readyState</span>==<span class="nu0">4</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160; &#160; &#160;<span class="kw1">if</span><span class="br0">&#40;</span>x.<span class="kw3">status</span>==<span class="nu0">200</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; r=x.<span class="me1">responseText</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; <span class="co1">// manipulate your result here</span></div>
</li>
<li class="li1">
<div class="de1">&#160;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; p=<span class="nu0">0</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160; &#160; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160;x.<span class="kw3">open</span><span class="br0">&#40;</span><span class="st0">&#34;GET&#34;</span>,url,<span class="kw2">true</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; &#160; &#160;x.<span class="me1">send</span><span class="br0">&#40;</span><span class="kw2">null</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&#160; &#160; &#160; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&#160; &#160;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Packed, this function is less than 500 bytes, much better than the 58kb of jQuery, heheh</p>
]]></content:encoded>
			<wfw:commentRss>http://www.overflow.biz/blog/lang/en-us/2009/05/20/simple-ajax-query-issue/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS and CSS Packer in PHP</title>
		<link>http://www.overflow.biz/blog/lang/en-us/2009/04/03/js-and-css-packer-in-php?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=js-and-css-packer-in-php</link>
		<comments>http://www.overflow.biz/blog/lang/en-us/2009/04/03/js-and-css-packer-in-php#comments</comments>
		<pubDate>Fri, 03 Apr 2009 16:02:46 +0000</pubDate>
		<dc:creator>z3n</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[packer]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://overflow.biz/blog/?p=43</guid>
		<description><![CDATA[Problem:
No decent css/js packers in php
Solution:
Source Here
This CLI based script will compress the input files detecting their formats and placing on a defined folder, easying the automation of multiple files compression.
have fun!
]]></description>
			<content:encoded><![CDATA[<p><strong>Problem:</strong></p>
<p>No decent css/js packers in php</p>
<p><strong>Solution:</strong></p>
<p><a href="http://www.overflow.biz/blog/~scripts/z_packer.rar" target="_blank"><strong>Source Here</strong></a></p>
<p>This CLI based script will compress the input files detecting their formats and placing on a defined folder, easying the automation of multiple files compression.</p>
<p>have fun!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.overflow.biz/blog/lang/en-us/2009/04/03/js-and-css-packer-in-php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

