preolad image

  • Thread starter Stephane Vander Clock
  • Start date
S

Stephane Vander Clock

hello,

i use this code to preload image :

<script language="JavaScript">
<!--
function preloadimages() {
var d=document;
if(d.images){
if (!d.preload) { d.preload=new Array(); }
var i,j=d.preload.length,a=preloadimages.arguments;
for(i=0; i<a.length; i++) {
if (a.indexOf("#")!=0){ d.preload[j]=new Image;
d.preload[j++].src=a; }
}
}
}


preloadimages('http://www.carlays.com/filedata/picture/w380h380/CA_P1_1_1769
643799.jpg','http://www.carlays.com/filedata/picture/w380h380/CA_P1_2_142876
519.jpg','http://www.carlays.com/filedata/picture/w380h380/CA_P1_3_396951326
..jpg','http://www.carlays.com/filedata/picture/w380h380/CA_P1_4_610955261.jp
g','http://www.carlays.com/filedata/picture/w380h380/CA_P1_5_1357663683.jpg'
,'http://www.carlays.com/filedata/picture/w380h380/CA_P1_6_1069878835.jpg','
http://www.carlays.com/filedata/pic...ata/picture/w380h380/CA_P1_8_314781705.jpg');

//-->
</SCRIPT>


You can see an exemple at http://www.carlays.com/T1


The only probleme is that this code is call before all image in the web page
are loaded ! (try http://www.carlays.com/T1 with a low internet connection
to see an exemple) ...
that mean i need to wait that all the image in preoladimage function are
loaded to see the entire content of my webpage :(


How can i delay the call of the function preloadimage after the moment of
all the image in the web page are loaded ?

thank you by advance
stephane
 
@

@SM

Stephane Vander Clock a ecrit :
i use this code to preload image :

try :

<body onload="postloadimages();">

<script language="JavaScript"><!--

function postloadimages(){
if(document.images)
{
// path Of Images
var p='http://www.carlays.com/filedata/picture/w380h380/';

MyImages = new Array('CA_P1_1_1769643799.jpg','CA_P1_2_142876519.jpg',
'CA_P1_3_396951326.jpg','CA_P1_4_610955261.jpg',
'CA_P1_5_1357663683.jpg','CA_P1_6_1069878835.jpg',
'CA_P1_7_1221341449.jpg','CA_P1_8_314781705.jpg');

a = new Array();
for(var i=0; i<MyImages.length; i++) {
a = new Image();
a.src = p+MyImages;
}
verifImages();
}
}

function verifImages() {
var ok=0;
for(var i=0;i<a.length;i++)
if(!(a.complete)) ok=1;
if(ok==1) setTimeout('verifImages()',200);
}

//--></SCRIPT>



--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:[email protected]
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
**************************************************************
 
S

Stephane Vander Clock

merci beaucoup

stephane

@SM said:
Stephane Vander Clock a ecrit :
i use this code to preload image :

try :

<body onload="postloadimages();">

<script language="JavaScript"><!--

function postloadimages(){
if(document.images)
{
// path Of Images
var p='http://www.carlays.com/filedata/picture/w380h380/';

MyImages = new Array('CA_P1_1_1769643799.jpg','CA_P1_2_142876519.jpg',
'CA_P1_3_396951326.jpg','CA_P1_4_610955261.jpg',
'CA_P1_5_1357663683.jpg','CA_P1_6_1069878835.jpg',
'CA_P1_7_1221341449.jpg','CA_P1_8_314781705.jpg');

a = new Array();
for(var i=0; i<MyImages.length; i++) {
a = new Image();
a.src = p+MyImages;
}
verifImages();
}
}

function verifImages() {
var ok=0;
for(var i=0;i<a.length;i++)
if(!(a.complete)) ok=1;
if(ok==1) setTimeout('verifImages()',200);
}

//--></SCRIPT>



--
******** (enlever/remove [OTER_MOI] du/from reply url) *******
Stéphane MORIAUX : mailto:[email protected]
Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)
http://perso.wanadoo.fr/stephane.moriaux/internet/
**************************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top