RSS Forums RSS
Please support our HTML and CSS advertiser: Lunarpages Web Hosting
Views: 21002 | Replies: 8
Reply
Join Date: Jul 2004
Posts: 3
Reputation: exesites is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
exesites exesites is offline Offline
Newbie Poster

preloading images

  #1  
Jul 7th, 2004
Hi all,

I am building a website for a small business which contains a number of images on several pages. I would like to preload all the images contained in the site but the scripts I have tried so far only work for the images on the page that the script is in.

Is there any way I can achieve this? If you want to check out the site the URL is http://www.simonlittle.co.uk

Any help much appreciated.

Ta
Paul
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2004
Location: In a house
Posts: 94
Reputation: Ragnarok is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Ragnarok Ragnarok is offline Offline
Junior Poster in Training

Re: preloading images

  #2  
Jul 7th, 2004
in the head tags somewhere place
<script language="JavaScript" type="text/JavaScript">
<!--
 function Preload() {
 	var args = simplePreload.arguments;
	document.imageArray = new Array(args.length);
	for(var i=0; i<args.length; i++) {
		document.imageArray[i] = new Image;
		document.imageArray[i].src = args[i];
	}
   }
 -->
 </script>

in the body tag place this as an atribute

onLoad="Preload('image1.jpg', 'image2.gif', 'image3.png', ...)"

You can add as many images as you need, but I strongly recomend not to bother using an image preload script, it means that people with slow modems will have to wait for the images to download. If there are to many images people might think that the page isn't loading and will go back or even close the browser and will never return again.
Reply With Quote  
Join Date: Jul 2004
Posts: 3
Reputation: exesites is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
exesites exesites is offline Offline
Newbie Poster

Re: preloading images

  #3  
Jul 9th, 2004
Hi Ragnarok,

Thanks for the script. However this, like the others I have tried only preloads the images on the first page. I take your point about the length of time to preload but I don't think that will be too much of an issue here and I would rather see the images appear straight away as the various pages are browsed.

There are 25 images on the site, three on the first page (index.htm) and the others spread over three further pages. I have the script in the <head> tag on index.htm and the arguments in the <body> tag on index.htm but only the three images on index.htm preload.

Am I missing something here or is it simply that each page has to preload its own images?

Cheers
Paul
Reply With Quote  
Join Date: Nov 2003
Location: Ohio
Posts: 778
Reputation: Zachery has a spectacular aura about Zachery has a spectacular aura about 
Rep Power: 8
Solved Threads: 20
Colleague
Zachery's Avatar
Zachery Zachery is offline Offline
The Geek Father

Re: preloading images

  #4  
Jul 9th, 2004
You cant preload for every script, you can only preload per page.
Firefox: no, its not the end all solution, it has its own issues and in time it will be just as insecure as IE, when its hit Firefox 6, if it makes it that far. Oh, and AOL pays for it, incase you didn't know.

Microsoft & Windows: If you hate it so much, move to linux, or bsd, or anything else, stop complaning and move on.
Good starting places: Gentoo Novell SUSE Fedora Core Apple
Reply With Quote  
Join Date: Jul 2004
Posts: 3
Reputation: exesites is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
exesites exesites is offline Offline
Newbie Poster

Re: preloading images

  #5  
Jul 12th, 2004
Hi Zachery,

Hmm I guessed that was the problem. As it happens the jpg files I have on the site are relatively small and load fairly quickly with a decent connection and with broadband there would be no problem at all.

Thing is I have a nine image "tour" where each picture is on a separate page and was looking for some way to ensure that these came up quickly when a visitor runs through them - obviously having a preload script on each page would be of no advatage whatsoever. Any ideas?

Cheers
Paul
Reply With Quote  
Join Date: Nov 2003
Location: Ohio
Posts: 778
Reputation: Zachery has a spectacular aura about Zachery has a spectacular aura about 
Rep Power: 8
Solved Threads: 20
Colleague
Zachery's Avatar
Zachery Zachery is offline Offline
The Geek Father

Re: preloading images

  #6  
Jul 12th, 2004
No, sorry, i dont do a whole lot with this type of thing :\

I wish you like in finding a good solution
Firefox: no, its not the end all solution, it has its own issues and in time it will be just as insecure as IE, when its hit Firefox 6, if it makes it that far. Oh, and AOL pays for it, incase you didn't know.

Microsoft & Windows: If you hate it so much, move to linux, or bsd, or anything else, stop complaning and move on.
Good starting places: Gentoo Novell SUSE Fedora Core Apple
Reply With Quote  
Join Date: Mar 2004
Location: In a house
Posts: 94
Reputation: Ragnarok is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
Ragnarok Ragnarok is offline Offline
Junior Poster in Training

Re: preloading images

  #7  
Jul 12th, 2004
All an image preload does is open an image before the browser exicuted the pages, it does no more or less. The only way to do what you want it to do is for the browser to have a cache, this is not avalable in every browser and a lot of people have their cache's turned off.

You also have to remember that not eveyone will have a decent broughband connection and if you want to become and kind of a decent web-designer you have to cater for all your browser's needs wether it be small file sized images or adding a little extra code to made the layout work in every browser
Reply With Quote  
Join Date: Mar 2005
Location: Amsterdam, The Netherlands
Posts: 23
Reputation: kcire is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
kcire's Avatar
kcire kcire is offline Offline
Newbie Poster

Solution Re: preloading images

  #8  
Mar 29th, 2005
Originally Posted by exesites
I would like to preload all the images contained in the site but the scripts I have tried so far only work for the images on the page that the script is in.
I have used the following for the same problem you described...

in your <head> put:
<style type="text/css">
.hiddenPic {display:none;}
</style>


and before your ending </body>, after your actual HTML and so, you put:
<img src="http://www.yourweb.com/images/picture1.jpg" alt="picture1"
title="picture1" height="131" width="700" class="hiddenPic">


For every picture you want to be preloaded you create a new <img> tag with the hiddenpic class in it...

After doing this I copied the list of <img> tags to every page involved. When doing this be sure not to forget the <head> part !

Of course I do not know if this will work...I think/hope it does...:rolleyes:
Last edited by kcire : Mar 29th, 2005 at 11:53 pm. Reason: wrong sentence...
Reply With Quote  
Join Date: Jun 2007
Posts: 1
Reputation: andrea_jazz is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
andrea_jazz andrea_jazz is offline Offline
Newbie Poster

Re: preloading images

  #9  
Jun 2nd, 2007
Originally Posted by kcire View Post
I have used the following for the same problem you described...

in your <head> put:
<style type="text/css">
.hiddenPic {display:none;}
</style>


and before your ending </body>, after your actual HTML and so, you put:
<img src="http://www.yourweb.com/images/picture1.jpg" alt="picture1"
title="picture1" height="131" width="700" class="hiddenPic">


For every picture you want to be preloaded you create a new <img> tag with the hiddenpic class in it...

After doing this I copied the list of <img> tags to every page involved. When doing this be sure not to forget the <head> part !

Of course I do not know if this will work...I think/hope it does...:rolleyes:


hi!
i'm happy to have red your comments, because it works, under IE and Firefox.
i used JavaScript image preload, but your way works better!

thank you,
bye
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:13 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC