<?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>Coders Cult &#187; javascript sleep function</title>
	<atom:link href="http://coderscult.com/tag/javascript-sleep-function/feed/" rel="self" type="application/rss+xml" />
	<link>http://coderscult.com</link>
	<description>PHP Website Development</description>
	<lastBuildDate>Thu, 05 Feb 2009 09:41:28 +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>Javascript Sleep Function</title>
		<link>http://coderscult.com/javascript-ajax/2009/02/05/javascript-sleep-function/</link>
		<comments>http://coderscult.com/javascript-ajax/2009/02/05/javascript-sleep-function/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 09:36:38 +0000</pubDate>
		<dc:creator>Mike Lopez</dc:creator>
				<category><![CDATA[Javascript/AJAX]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[javascript sleep]]></category>
		<category><![CDATA[javascript sleep function]]></category>

		<guid isPermaLink="false">http://coderscult.com/?p=62</guid>
		<description><![CDATA[I&#8217;ll make this short and quick. I&#8217;ve been searching the web for a Javascript sleep function that works and came across this. It was presented as a class but what I needed was just a function so I rewrote the code a bit. Here&#8217;s the end result of my Javascript sleep function which I named, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll make this short and quick.  I&#8217;ve been searching the web for a Javascript sleep function that works and came across this.  It was presented as a class but what I needed was just a function so I rewrote the code a bit.  Here&#8217;s the end result of my Javascript sleep function which I named, well, jsleep.<span id="more-62"></span></p>
<pre lang="javascript">
function jsleep(s){
	s=s*1000;
	var a=true;
	var n=new Date();
	var w;
	var sMS=n.getTime();
	while(a){
		w=new Date();
		wMS=w.getTime();
		if(wMS-sMS&gt;s) a=false;
	}
}
// how to use
alert('in the beginning there was a pause...');
jsleep(3);
alert('3 seconds after... the pause was gone.');
</pre>
<p>I&#8217;ve tested it in Google Chrome, Firefox 3 and Internet Explorer 7.  Works like a charm.</p>
]]></content:encoded>
			<wfw:commentRss>http://coderscult.com/javascript-ajax/2009/02/05/javascript-sleep-function/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

