Sleep Function for JavaScript like PHP
I need to implement a general sleep function replacement for javascript. It should be possible to call it multiple times on a page. I googled and found some code on ozzu forums, which didnt work for me. I get alert messages immediately without waiting 2 or 5 seconds. I tried it (with MSIE+FF) as following :
<script language="javascript">
function sleep(delay)
{
var start = new Date().getTime();
while (new Date().getTime() < start + delay);
}
sleep(2);
alert("first");
sleep(5);
alert("second");
</script>
Is there an easy way to write a general sleep function for javascript?
Similar entries
- Random tip / info-box with javascript array
- Google's bloody javascript annoying
- How to hide / encrypt CCK Email field with JS against spammer
- Hide your email address + mailto link with javascript from spammer
- How to use custom function aliases in PHP
- Change background color onmouseover with Javascript
- Check password safety with JavaScript while typing
- Call to undefined function money_format()
- Web2 style secure & flexible free php contact form with easy setup
- WebSearch
- web development tool Firebug for Firefox
- PHP get page title function
- php
- Redirect webpages with HTML, PHP, .htaccess, Java+Script, CGI-Perl, ASP.NET and ColdFusion
- Redirect a query to multiple search engines with one form and javascript
- Between operator in PHP
- Web2 style sicheres & flexibles free PHP-Formular with easy setup
- Common HTML / Web colors
- Javascript Frameworks and Ajax Jquery
- Register Globals Emulator for PHP












Post new comment