Hding content until after load

For a project I am currently working on, we are using dynamic html and javascript to display content based on what menu link the user clicks on.  I've noticed one little nuance though that I would like to fix.

In the body's onload event, we call our javascript function to hide all the content cells except for the welcome page.  The problem is that with network lag, all the content for the page shows up initially until the page is finished loading and the onload event fires, hiding the data we dont want to show.  Is there a way to prevent this?  We would like everything to be hidden initially, and then when the onload fires, we can unhide the welcome page or something to that effect.  Any ideas?
porkVTAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
cLFlaVAConnect With a Mentor Commented:
Have you looked into the setTimeout() function?

You could have everything initially hidden, and on the body's onload event, you could call a function that will unhide everything...

<head>
<script language="JavaScript">
<!--
function unHideStuff() {
    for (var i = 0; i < 5; i++) {
        document.getElementById('the_div_' + i.toString()).style.display = 'block';
    }
}
-->
</script>
</head>

<body onload="return unHideStuff();">
<div id="the_div_0" style="display: none;">stuff...</div>
<div id="the_div_1" style="display: none;">stuff...</div>
<div id="the_div_2" style="display: none;">stuff...</div>
<div id="the_div_3" style="display: none;">stuff...</div>
<div id="the_div_4" style="display: none;">stuff...</div>
0
 
cLFlaVACommented:
By the way -- the reference to setTimeout() was an initial idea I had, then abandoned.  Sorry to confuse you :)
0
 
arataniCommented:
Why dont you hide all the elements before and then unhide it as needed by using style = "display: none;"? That would make more sense if you don't want the elements showing up anyway?

AJ
0
 
RoonaanCommented:
<style>
body * {display:none;}
body.loaded * {display:inherit;}
</style>
<body onload="this.className='loaded';">
stuff
</body>

-r-
0
 
dakydCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

ACCEPT cLFlaVA  -- http://Q_21147802.html#12169317

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

dakyd
EE Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.