Forum Moderators: open

Message Too Old, No Replies

Hiding Thumbnails until all are Loaded

         

gph

12:52 am on May 9, 2002 (gmt 0)

10+ Year Member



I'm on a fast cable connection and am not sure how to test this. Could someone tell me if what I'm doing is correct?

The page consists of a left table that is 200 px wide and includes absolutely positioned text navigation. The right table fills the rest of the page with thumbnails.

I put this in the head:

function load() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('hide').style.visibility = 'hidden';
}
else {
if (document.layers) { // Netscape 4
document.hide.visibility = 'hidden';
}
else { // IE 4
document.all.hide.style.visibility = 'hidden';
}
}
}

And this after the left table and before the thumbnails table in the body:

<div id="hide" style="position: absolute; left:201px; top:0px; background-color: #525252; layer-background-color: #525252; height: 100%;"></div>

Thank you

joshie76

4:14 pm on May 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure what your after. Err, is it not working or do you need to test it on a slow modem?

If you need to test it on a slow modem stickymail me and I'll try it at home.

If it's not working, what happens?

It looks like you're trying to hide your images with a 'screen' layer. The best way to do it would be to put a div around your pictures with style="visibility:hidden". Then in the load function (called from the body onload event <body onload="load()">) set the visibility of your surrounding div to visible.

Let me know if I'm off on the wrong track.

<edited to turn off smilies>

(edited by: tedster at 4:30 pm (utc) on May 9, 2002)

gph

4:25 pm on May 9, 2002 (gmt 0)

10+ Year Member



No that's what I'm after Joshie. I'd like to show the left navigation table immediately but hide the images until they are all loaded so they can all display at the same time.

So if I set the div that surrounds the images to become visible in the body tag it would cover them until they’re all loaded and ready for viewing?

joshie76

4:47 pm on May 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Anything inside the <div style="visibility:hidden"> will be invisible to the user (just get the background) until the onload event fires and the visibility is set to visible. Then the contents of your layer, images and all, will appear before your very eyes.

J

PS If you're images could take a while to load you might want to have another div saying 'loading' or something that shows until the page loads... otherwise the user might think they've hit a blank page! enjoy ;)

gph

5:32 pm on May 9, 2002 (gmt 0)

10+ Year Member



Thanks Joshie, here's what I've done. I set the colour of the div to white and my page background to black.

I'm obviously doing something wrong because it shows the images in IE6 with a 3px high white line across the bottom of the thumbnails table. The images don't show at all in NN4 and NN6.

<head>
<SCRIPT LANGUAGE="JavaScript">
function load() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('cover').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.cover.visibility = 'visible';
}
else { // IE 4
document.all.cover.style.visibility = 'visible';
}
}
}
</script>
</head>

<body onLoad="load()">

<The left table set to width: 200px and height: 99.5%>

The div around the thumbnails table:

<div id="cover" style="visibility: hidden; position: absolute; left:201px; top:0px; background-color: #ffffff; layer-background-color: #ffffff; height: 99.5%;">

<The table here>

</div>

gph

5:35 pm on May 9, 2002 (gmt 0)

10+ Year Member



In reading my reply I noticed an error:

absolute; left:201px;

Should be:

absolute: left:201px;

The results are almost the same, the difference is IE6 shows the images with a large white border.

joshie76

6:58 pm on May 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK.. this should work. You shouldn't need to apply an extra background-colors on the layer etc...

<html> 
<head>
<SCRIPT LANGUAGE="JavaScript">
function showonload() {
if (document.getElementById) { // DOM3 = IE5, NS6
document.getElementById('images').style.visibility = 'visible';
}
else {
if (document.layers) { // Netscape 4
document.images.visibility = 'visible';
}
else { // IE 4
document.all.images.style.visibility = 'visible';
}
}
}
</script>
</head>
<body onLoad="showonload()">
The div around the thumbnails table:
<div id="images" style="visibility: hidden; position: absolute; left:201px; top:0px;">
The table here containing your images
</div>
</body>
</html>

gph

7:08 pm on May 9, 2002 (gmt 0)

10+ Year Member



Thanks Joshie, it works just fine :-)

gph

7:11 pm on May 9, 2002 (gmt 0)

10+ Year Member



By the way. I'm testing it but changing a couple of the images into very large files.