View Full Version : preloading images
Weapon
December 8th, 2001, 21:23
is there a javascript that preloads all my images, and then after loadin' them redirects the user to a different page? you know, like one of those flash intro's but in javascript. Also if possible show a loading bar? :confused: , ta ta :D
meow
December 9th, 2001, 04:33
If I understand it right you just have to assign the images to variables for them to load.
if (document.images) {
img1 = new Image();
img1.src = "path/to/yourImage.gif"
img2 = new Image();
img2.src = "path/to/yourImage.gif"
//etc etc etc
If you want a full script I had this. You'll have to test it yourself. :mad:
function preloadImages()
{
if (document.images)
{
var imgFiles = preloadImages.arguments;
if (document.preloadArray==null) document.preloadArray = new Array();
var i = document.preloadArray.length;
with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#")
{
preloadArray[i] = new Image;
preloadArray[i++].src = imgFiles[j];
}
}
}
-------
<body onload="preloadImages(1.jpg,2,jpg,3.jpg.....999.jpg);">
:fork:
LeX
December 10th, 2001, 07:15
http://www.dynamicdrive.com/dynamicindex4/preloadimage.htm - Click (http://www.dynamicdrive.com/dynamicindex4/preloadit.htm) to see the preloading first
Weapon
December 10th, 2001, 21:15
thx d00d (as in LeX and not j00 meow :D j/k
Ashed
December 11th, 2001, 05:44
That's a nice script. I've seen it somewhere before and didn't know what it was (wans't paying attention) so I just skipped the preloading bit.
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.