?
Solved

Hding content until after load

Posted on 2004-09-28
6
Medium Priority
?
1,318 Views
Last Modified: 2012-06-21
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?
0
Comment
Question by:porkVT
5 Comments
 
LVL 13

Accepted Solution

by:
cLFlaVA earned 1000 total points
ID: 12169317
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
 
LVL 13

Expert Comment

by:cLFlaVA
ID: 12169320
By the way -- the reference to setTimeout() was an initial idea I had, then abandoned.  Sorry to confuse you :)
0
 
LVL 4

Expert Comment

by:aratani
ID: 12169571
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
 
LVL 49

Expert Comment

by:Roonaan
ID: 12170286
<style>
body * {display:none;}
body.loaded * {display:inherit;}
</style>
<body onload="this.className='loaded';">
stuff
</body>

-r-
0
 
LVL 19

Expert Comment

by:dakyd
ID: 15646175
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question