Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hding content until after load

Posted on 2004-09-28
6
Medium Priority
?
1,309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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…

715 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