View Full Version : Preload images then redirect
MarkyBoy
01-09-2003, 05:00 PM
Hi,
Does anyone have a script which would allow me to preload some images into memory (without displaying), then redirect to another page AFTER all the images have finished loading?
Thanks for any help.
If you don't get any prewritten scripts, do a search in the archive for checking to see if an image is loaded. Once you have that portion you can simply do a window.location.href="newlocation"
Algorithm
01-09-2003, 10:20 PM
function loadImg(src){
var i=loadImg.a.length;
loadImg.a[i] = new Image();
loadImg.a[i].src = src;
}
loadImg.a = new Array();
loadImg('img1.gif');
loadImg('img2.gif');
loadImg('img3.gif');
// Repeat as often as necessary
window.onload = function(){
// This code will execute once all images have loaded.
}
<script language="JavaScript">
<!--
var YourImages = new Array("pic1.jpg","pic2.jpg","pic3.jpg","pic4.jpg")// list images to preload
var preloadYourImages=new Array()
for (i=0;i<=YourImages.length-1;i++) {
preloadYourImages[i]=new Image()
preloadYourImages[i].src=YourImages[i]
}
window.onload = function (){
location="yourpage.htm"
}
// -->
</script>
beetle
01-09-2003, 10:36 PM
I've used this script (http://www.dynamicdrive.com/dynamicindex4/preloadit.htm) before in that fashion on this site (http://www.ccsb.com/art.htm)
Never had any problems
whammy
01-10-2003, 12:08 AM
Hmm, never ran into that one, it's pretty nice! :D
MarkyBoy
01-10-2003, 08:35 AM
Thanks folks, much appreciated
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.