» posted on Thursday, July 17th, 2008 at 11:24pm by Dan
How To: Create a Simple Visual “Loading” Effect
If you've got a script that takes a while to load and want to make your user aware that everything is alright, then this tool is for you. The idea is simple – display the message before the labor intensive part of the script runs, and then using CSS after the labor intensive part of the script, hide the message. If you're using a language that provides a buffer (ASP for instance), make sure you turn the buffer off first, or this won't have any effect. (eg. Response.Buffer = False) Example (See it in action):
<?php
ini_set('implicit_flush', 'on');
echo '<p id="loading_msg"><img src="http://img520.imageshack.us/img520/4950/loadingvp7.gif" alt="" style="vertical-align: middle;" /> Loading...</p>';
// Code that takes forever here, could of course be any language
sleep(5); // Only for demonstration
echo '<script type="text/javascript">
window.onload = init;
function init() {
document.getElementById("loading_msg").style.display = "none";
}
</script>';
echo '<p>Woohoo, five seconds passed.</p>';
require_once('includes/trackers.inc.php');
?>
» Keywords
army
asp
buffer
cell phone
Code
css
domain tools
domain valuation
free flv player
freelance
free mp3 player
free mp4 player
google pagerank
haval
internet through cell phone
loading
md5
motorola razr
phone
PR
recordset
sha1
sha256
sha384
sha512
snefru
soldiers
voice mail
web flv player
website monitoring
Web Tools
![[del.icio.us]](http://www.randomtools.net/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.randomtools.net/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://www.randomtools.net/wp-content/plugins/bookmarkify/facebook.png)
![[Google]](http://www.randomtools.net/wp-content/plugins/bookmarkify/google.png)
![[Reddit]](http://www.randomtools.net/wp-content/plugins/bookmarkify/reddit.png)
![[Slashdot]](http://www.randomtools.net/wp-content/plugins/bookmarkify/slashdot.png)
![[StumbleUpon]](http://www.randomtools.net/wp-content/plugins/bookmarkify/stumbleupon.png)