Preloader...

M

Mateo

Hi!

I have web aplication,lots of scripting and server-side work, and it takes
some time to load (if not cached). I would like to make some of those
preloaders, you know, like progress bar or something saying : loading,
please wait.... Is JS apropriate tool for such action? Any ideas? Any
scripts on-line?
 
R

Randy Webb

Mateo said the following on 1/8/2007 2:26 PM:
Hi!

I have web aplication,lots of scripting and server-side work, and it takes
some time to load (if not cached). I would like to make some of those
preloaders, you know, like progress bar or something saying : loading,
please wait.... Is JS apropriate tool for such action? Any ideas? Any
scripts on-line?

Put an animated "loading" image on the page.
Hide all other content.
onload hide the image and show the rest of the page.
 
M

Mateo

Put an animated "loading" image on the page.
Hide all other content.
onload hide the image and show the rest of the page.

yeap, sounds easy.... but...
how can I catch that event when page is loaded from JS???

and how can I hide all other content except this only one image?

thanx!
 
R

Randy Webb

Mateo said the following on 1/8/2007 3:44 PM:
yeap, sounds easy.... but...
how can I catch that event when page is loaded from JS???

and how can I hide all other content except this only one image?

<body>
<div id="bodyContent" style="visibility:hidden">
All your content goes here
</div>
<div id="loadingDiv" style="visibility:visible">
<img src="loading.gif">
</div>

<script type="text/javascript">
window.onload = foo;
function foo(){
document.getElementById('bodyContent').style.visibility="visible";
document.getElementById('loadingDiv').style.visibility="hidden";
}
</script>

And then use CSS to position the two div elements.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
R

RobG

Mateo said:
yeap, sounds easy.... but...
how can I catch that event when page is loaded from JS???

and how can I hide all other content except this only one image?

If script is disabled, not available, errors before displaying the
content or the load event doesn't occur, those users will see only the
"loading..." image.

Back in the good old days, some browsers showed a blank page until all
content was loaded while others showed the page as it loaded. Users
showed a marked preference for the latter, which is why (all?) modern
browsers show the page as it loads.

Reverting to a scheme abandoned long ago in favour of a better one
doesn't make much sense - but hey, it's your page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top