It sounds like you are working with a CGI, you could just paginate them. For example build a list, then display so many per page.
use strict;
use warnings;
use CGI;
use constant PICS_PER_PAGE => 20;
my @pics = ('pic1.jpg', 'pic2.jpg');
my $cgi = new CGI;
my $start = $cgi->param('start') || 0;
foreach($start..($start + PICS_PER_PAGE - 1)){
last unless(defined $pics[$_]);
print qq(<IMG src="$pics[$_]">);
}
my $newstart = $start + PICS_PER_PAGE;
print qq(<INPUT type="hidden" name="start" value="$newstart">);
Replace PICS_PER_PAGE with the number of pictures per page, and load @pics, with the picture names.
You can't really check to see if the browser has already loaded the images, but you can generate JavaScript to only preload the images that are going to be displayed on this particular page. You already have the list of images that are going to be displayed on the current page.
Update:Took care of default case, where $start was undef.
Update2:Gave more explanation. I read the question too quick, and didn't answer all of it.
| [reply] [d/l] |
Better off just doing a preload of all of them (pretty small anyway), you can't do anything from the server side, short of adding an Apache module or something to check that the client had requested and been sent at least half of the images. Or you might be able to do it with Perl and server logs, provided you have permission to change the format of your server logs and that Perl has permission to read them... but this is very silly. I think you're better off just preloading all and not worrying about it. And now for something completely different.
___________________________
10 poke53280,a:poke53281,a
20 ?"c64 rules ";
30 a=a+1:ifa=16thena=0:goto 10
| [reply] |
check that the client had requested and been sent at least half of the images.
Except that that's impossible. The HTML page must be sent first so that the client will know which images to request. If the server doesn't send the HTML, it will never receive requests for the images in the first place, and if it sends the HTML, the client will display it.
| [reply] |
You can't verify it with perl, but i think there are possibilities with client-side methods such as javascript, java or flash, but who wants that... :)
I don't know if it gives the results you want, but you may
want to look at those.
| [reply] |
| [reply] |
Agreed. I'll add this: The behavior I witness in my browser is that the browser will load the page, parse it, and then make requests for the images. But even with javascript, I'm not sure that you can prevent the display of the page until all the images are loaded.
| [reply] |
Sorry about the delay inresponding but new job, etc. I had to be away for a while. Thanks for all of the replies!
The problem I was experiencing was one that I had a page that would load about half of the images, never all of them. I did get a chance to get with a couple other people here locally and decided to go with the preload even though Javascript and I don't get along very well. Read that as I am notas good at it as I am perl, and I rate myself as an extreme novice at Perl but hopefully learning more everyday..... :-)
Thanks again for all of the replies!
Jim
| [reply] |