Pre Loading For Pictures

Hi:<br />
<br />
I have two questions, but first, just a bit of an explanation.<br />
<br />
I have been requested to design a Home Page for a visitor to Canada, from Germany. She wants the pages to show a great number of pictures and in a "slideshow" format. Approximately 75 pictures to be displayed over 5 pages. Now the questions:<br />
<br />
1. Can someone please give me the HTML coding or the JavaScript that will make the viewer's browser Download <!--more--> the pictures before it displays??<br />
<br />
2. With this coding, should it be placed only on the opening page?? And if so, will it then Download <!--more--> all the pictures required for the 5 pages? Or should the code be placed on each page so only the relative pictures for that page are pre loaded and cuts down the loading time for the viewer??<br />
<br />
Thanks,<br />
<br />
Webspanner<!--content-->Webspanner,<br />
Code is as follows:<br />
<br />
<script language="javascript"><br />
<br />
pic1 = new Image();<br />
pic1.src = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/">http://www.htmlforums.com/archive/index.php/</a><!-- m -->"pic1.gif";<br />
<br />
</script><br />
<br />
(where pic1 one is the name of your image...)<br />
<br />
Just repeat this for all images you wish to preload. Then, where you want them to appear on your page, just put:<br />
<br />
<script><br />
document.write('<img src=http://www.htmlforums.com/archive/index.php/"' + pic1.src + '">');<br />
</script><br />
<br />
As for your other question, no way anyone is gonna wait for all 75 images to preload on the front page. Split them out over the 5 pages.<br />
<br />
:)<!--content-->This code is to be put at the opening page and it has this cool loading bar... really proffesional plus a redirection after that!!! but be very careful... just because you have a pre loader does'nt mean that you don't have to optimise your pictures hey? this ones from my frth coming site. It comes with two images too: red.gif and black.gif (attached)<br />
<br />
any way here it is:<br />
<br />
<html><br />
<head><br />
<title>loading nqo's site... please wait...</title><br />
<script language="JavaScript1.1" type="text/javascript"><br />
<!--<br />
var goTo = "www20.brinkster.com/nqobizitha/index3.html"<br />
var barWidth = 200<br />
var barHeight = 25<br />
var imgtoPreload = new Array("images/header.gif","images/header2.gif","images/anim.gif")<br />
if (document.images) {<br />
var barImg = new Array() <br />
barImg[0] = new Image(1,1)<br />
barImg[0].src = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/">http://www.htmlforums.com/archive/index.php/</a><!-- m -->"black.gif"<br />
barImg[1] = new Image(1,1)<br />
barImg[1].src = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/">http://www.htmlforums.com/archive/index.php/</a><!-- m -->"red.gif"<br />
var imgtoNow = new Array(),coverage = Math.floor(barWidth/imgtoPreload.length),currCount = 0<br />
var loaded = new Array(),i,covered,timerID<br />
var barWidthL = barWidth%coverage<br />
}<br />
function loadImages() { <br />
for (i = 0; i < imgtoPreload.length; i++) { <br />
imgtoNow = new Image()<br />
imgtoNow.src = <!-- m --><a class="postlink" href="http://www.htmlforums.com/archive/index.php/imgtoPreload">http://www.htmlforums.com/archive/index ... gtoPreload</a><!-- m --><br />
}<br />
for (i = 0; i < imgtoNow.length; i++) { <br />
loaded = false<br />
}<br />
checkLoad()<br />
}<br />
function checkLoad() {<br />
if (currCount == imgtoNow.length) { <br />
location.replace(goTo)<br />
return<br />
}<br />
for (i = 0; i <= imgtoNow.length; i++) {<br />
if (loaded == false && imgtoNow.complete) {<br />
loaded = true<br />
eval("document.img" + currCount + ".src=http://www.htmlforums.com/archive/index.php/barImg[1].src")<br />
currCount++<br />
}<br />
}<br />
timerID = setTimeout("checkLoad()",10) <br />
}<br />
//--><br />
</script><br />
</head><br />
<body bgcolor="black" text="white" link="white" alink="white" vlink="white"><br />
<center><br />
loading nqo's site... please wait...<br />
<script language="JavaScript1.1" type="text/javascript"><br />
<!-- <br />
if (document.images) {<br />
var preloadBar = ''<br />
for (i = 0; i < imgtoPreload.length-1; i++) {<br />
preloadBar += '<img src=http://www.htmlforums.com/archive/index.php/"' + barImg[0].src + '" width="' + coverage + '" height="' + barHeight + '" name="img' + i + '">'<br />
}<br />
preloadBar += '<img src=http://www.htmlforums.com/archive/index.php/"' + barImg[0].src + '" width="' + (barWidthL+coverage) + '" height="' + barHeight + '" name="img' + (imgtoPreload.length-1) + '">'<br />
document.write(preloadBar)<br />
loadImages()<br />
}<br />
//--><br />
</script> <br />
<p>If the progress bar stops or does not move, please <a href=http://www.htmlforums.com/archive/index.php/"www20.brinkster.com/nqobizitha/index3.html">click here</a>...<br />
</center><br />
</body><br />
</html><!--content-->Hi nqobizitha:<br />
<br />
Thanks very much for all the coding and for taking the time to answer my posting for help.<br />
<br />
Unfortunately, I'm afraid this doesn't seem to work, probably because of the "slideshow" format.<br />
<br />
Inch has given me some coding to try and he's working with me on that.<br />
<br />
Thanks again, much apprecitated. :) <br />
<br />
Regards,<br />
Webspanner<!--content-->
 
Back
Top