Trackbacks
- No Trackbacks
“People count up the faults of those who keep them waiting”
Seems like I kept them busy decoding this loading bar

How to create a loading bar
Recently, while browsing I landed on a page on StackOverflow.com where people were discussing about how I implemented this loading bar on CSSJockey.com. I could sense a lot of confusion in the discussion so thought I would take the mystery out as I love to share best practices. Here’s how you can create a loading bar in few steps..
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(window).load(function(){
$("#loading").hide();
})
</script>
<div id="loading"> Loading content, please wait.. <img src="loading.gif" alt="loading.." /> </div>
Make sure you add this code just below the starting <body> tag so it should be downloaded first.
#loading {
position:absolute;
width:300px;
top:0px;
left:50%;
margin-left:-150px;
text-align:center;
padding:7px 0 0 0;
font:bold 11px Arial, Helvetica, sans-serif;
}
Use your imagination and create something nice & unique.
View Demo | Download Source Code
Your comment, suggestion and feedback is highly appreciated.
There’s more to come to stay tuned…
I see how this works for a page loading, but do you know how to do something like this if you are waiting for the content to be generated in php?
Thanks
Huh, i can’t see the preview image. Btw, nice work.
well i would like to know how to make my loading bar appear first and then once the page is done loading it should redirect the person .. any ideas ?? please email me at arjhun.s@gmail.com .. thanx people
Great tip, thank you.
Great work.. !!
Thanks for sharing.
Thanks for the tutorial, i will use that in my page. I wish it would also show the percantage…
This is wonderful! Thank you so much!
Quick question:
How would I call that top function if a form was submitted? I have a file upload section I am working on and could use a cool loading bar like this when the upload form is submitted…
Thanks for the post. Relatively easy….it took me some time to get the jQuery to work.
Good post dude.
hi i have tried progress bar in my site.it works fine. but it not displays all the time. Moreover while displaying this image, it looks displaying in separate page. i want to display it in my current page when the page takes more time to load……
Any ideas…
Mohit Aneja,
That was very helpful Mohit!! I never thought that you’ll find my question in Stackoverflow!
I’ll definitely never forget your helpful spirit!
How did you know about the question in Stackoverflow? You are not even registered user yet!
Thanks for sharing – Nifty tip!
excellent tutorial.
Thanks for sharing, I will try this on my website…
22 Jan, 2010
Hi, Mohit.
Another great tips after Santa’s says on dec.
I will try in myblog. Thanks