Forum Moderators: coopster & phranque

Message Too Old, No Replies

Loading images in sequence

so the top one is fully displayed before a second one starts

         

Larry

7:14 pm on May 29, 2004 (gmt 0)

10+ Year Member



I am relatively new to cgi and server side includes. On my site I have a picture page with a single column of images, in plain xhtml. I would prefer to use a cgi script that would load the top picture first and then the one below it, on down to the end. As it is, because of the random order of image loading on my plain page, I keep the number of pictures per page to a minimum.

Is there a Perl script method that I can use, or a script that I can obtain that performs this top-down order of loading? I have done many Google searches for this topic to no avail.

Larry

MichaelBluejay

10:40 pm on May 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I thought that all browsers automatically loaded images from top to bottom?

Anyway, I'm pretty sure you can't set image-loading order with Perl, since all Perl does is send data to the browser -- it can't check for or control events. What you'd want to use is JavaScript, which can check for and control browser events.

<IMG onload=document.secondImage.src="image2.jpg">

<IMG name=secondImage src="pixel.gif">

Have the second image be a single pixel so even if it loads first it loads quickly and the user doesn't see it. Then after the first image loads it will automatically change the second image to "image2.jpg".

If you need to load many more images then you'd use a function:

<HEAD>
<script language=javascript>
function loadImages {

document.secondImage.src = "image2.jpg";
document.thirdImage.src = "image3.jpg";
document.fourthImage.src = "image4.jpg";
}
</script>
</HEAD>

<BODY>

<IMG onload="loadImages()">

<IMG name=secondImage src="pixel.gif">

<IMG name=thirdImage src="pixel.gif">

<IMG name=fourthImage src="pixel.gif">

</BODY>
---------
Moderator, can you move this message to the JavaScript forum if appropriate? Thanks!

Larry

2:59 am on May 30, 2004 (gmt 0)

10+ Year Member



I thought that all browsers automatically loaded images from top to bottom?
Anyway, I'm pretty sure you can't set image-loading order with Perl

I guess all images do start loading from top down, and what I am finding is after an image has begun loading, so have other images on the page.

The one developing on the monitor is taking more time over a dialup connection to complete because it is competing with all the others. Sometimes, a picture further down has made more progress than the one at the top. This is a clearer statement of my original intent than my first post, and more in keeping with my small-print topic heading.

I generally prefer to use server side scripting because it is universally available to all visitors, while client side scripting can either be unavailable or disabled on the visitor's computer.

In this instance, however, I could use a JavaScript routine because whether it is available or not to the user, the pictures will still be delivered -- just not one at a time.

I will pursue further questioning on JavaScript in that forum, and will watch for more server side input here. Thanks Michael for your thoughts!

Larry