troubleshooting Question

Hiding DIVs using window.onload

Avatar of PLBS
PLBS asked on
JavaScript
3 Comments1 Solution346 ViewsLast Modified:
I am about to build a page containing a complex custom JavaScript slideshow.  I have a couple critical questions before I begin:

1)  For very specific reasons, I want to put each photo in its own DIV container, and execute the slideshow by changing the "display" value of the DIVs.  To accommodate non-JavaScript-enabled visitors, I figured I would have the page load with all the DIVs displaying, then set display: none via JavaScript window.onload for all the DIVs except the first one in the slideshow.  So... as long as I have that "hiding" code executing first in the onload event, will the DIVs that are going to be hidden start off briefly visible JavaScript enabled users?  In other words, there won't be a brief flicker of all the DIVs showing before they're hidden, right?  I always assumed the onload event executed after the page was loaded into memory but before it was rendered on the screen.  Would it be better to put a script tag inline after each DIV that will set display: none, or is using the onload event a better way?

2)  I'm going to use neondragon's reflection script to place a reflection below each photo (that is the reason I'm resorting to rotating images via DIV visibility rather than img src.)  That script works great, but it takes a second or so to calculate and render the reflection of an image.  I'm assuming that, even though all but one DIV will be hidden, if I execute the reflection script on the hidden images it will still create the reflection so that, when the DIV is made visible, the reflection will already be created.  Is this correct?  The reflection script executes onload and builds a reflection for every image with class="reflect" so I assume it will still build the reflection even within an "invisible" DIV.  Am I right about this?

Thanks!!!!
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros