Tech from Hel
Helene's ramblings on Wordpress, jQuery and other web technologies.
rss
twitter
  • About
  • Projects

Posts Tagged ‘sleep’

Sleeping with Javascript

no comments
Posted on Jun 7 2009 by helene

When I went looking for a built-in “sleep()” function in Javascript, I quickly learned that it does not exist. This is surprising considering that “sleep()” is in all other languages that I have used. To get around this javascript shortcoming, I decided to create my own sleep function. The result is a function that loops internally until the number of seconds passed is greater than the argument value, “naptime”.

Initial tests of “sleep()” were successful, however, I soon discovered that most browsers will interrupt “sleep()” and show a “Slow/Busy script” dialog message whenever the “naptime” argument is greater than 10 seconds (7 seconds in IE). Trying to work around this problem was too much effort, so I left the script as is. If you use this function, I recommend a “naptime” of less than 10 seconds so your site visitors won’t encounter this “slow script” dialog message.

Below are some examples of “sleep()” in javascript. Just click on a link below to start sleeping for the preset amount of seconds shown.

Read more…


Read More

  Tags: jquery, sleep Category: javascript

Categories

  • Blogging
  • javascript
  • Miscellaneous
  • Multimedia
  • MySQL
  • Plugins

Recent Posts

  • WassUp Works Well with WP Widget Cache
  • CTRL+Z Undo: The Keyboard Shortcut You Can’t Do Without
  • A Fine Fix for “get_currentuserinfo undefined”
  • Optimize with MySQL Procedure Analyse
  • Sleeping with Javascript

Popular Posts

  • Horizontal Submenus for Wordpress Admin Plugins
  • Flv Videos in a Thickbox
  • YouTube Videos in a Thickbox
  • Sleeping with Javascript
  • Installing a More Secure Wordpress

Archives

Ads


  • About
  • Projects
Powered by Wordpress  |  Designed by WebTreats