Hello folks I have a rolling image script that works fine except that
the images do not seem
to be preloading properly. The images are still being pulled on every
interval from the
server according to the logs...is it because I am using the
document.write method? Is that forcing a refresh?
<SCRIPT language="JavaS cript" type="text/javascript">
// BEGIN rolling images code
/* define width and height of images */
var pic_width=200;
var pic_height=200;
// define the length of time to stay on each image
// 1000 = 1 second
var delay=3000;
/* define image urls */
if (document.image s)
{
pic1= new Image(pic_width ,pic_height);
pic1.src="myimg 1.gif";
pic2= new Image(pic_width ,pic_height);
pic2.src="myimg 2.gif";
pic3= new Image(pic_width ,pic_height);
pic3.src="myimg 3.gif";
pic4= new Image(pic_width ,pic_height);
pic4.src="myimg 4.gif";
pic5= new Image(pic_width ,pic_height);
pic5.src="myimg 5.gif";
pic6= new Image(pic_width ,pic_height);
pic6.src="myimg 6.gif";
pic7= new Image(pic_width ,pic_height);
pic7.src="myimg 7.gif";
pic8= new Image(pic_width ,pic_height);
pic8.src="myimg 8.gif";
}
var pics= new Array(8)
pics[0]=pic1.src;
pics[1]=pic2.src;
pics[2]=pic3.src;
pics[3]=pic4.src;
pics[4]=pic5.src;
pics[5]=pic6.src;
pics[6]=pic7.src;
pics[7]=pic8.src;
var numpics=8;
var thenum=0;
imgName="img1";
function change_it()
{
if (document.image s)
{
document.write( "<IMG SRC='"+pics[thenum]+"' border='0'
width='"+pic_wi dth+"' height='"+pic_h eight+"' name='img1'>\n" );
setTimeout('cha nge_it2()',dela y);
}
}
function change_it2()
{
var x=0;
thenum+=1;
if (thenum>numpics-1)
thenum=0;
document[imgName].src=pics[thenum];
x+=1;
setTimeout('cha nge_it2()',dela y);
}
</script>
then on my pages body i have
<SCRIPT language="JavaS cript" type="text/javascript">
<!--
change_it()
//-->
</SCRIPT>
the images do not seem
to be preloading properly. The images are still being pulled on every
interval from the
server according to the logs...is it because I am using the
document.write method? Is that forcing a refresh?
<SCRIPT language="JavaS cript" type="text/javascript">
// BEGIN rolling images code
/* define width and height of images */
var pic_width=200;
var pic_height=200;
// define the length of time to stay on each image
// 1000 = 1 second
var delay=3000;
/* define image urls */
if (document.image s)
{
pic1= new Image(pic_width ,pic_height);
pic1.src="myimg 1.gif";
pic2= new Image(pic_width ,pic_height);
pic2.src="myimg 2.gif";
pic3= new Image(pic_width ,pic_height);
pic3.src="myimg 3.gif";
pic4= new Image(pic_width ,pic_height);
pic4.src="myimg 4.gif";
pic5= new Image(pic_width ,pic_height);
pic5.src="myimg 5.gif";
pic6= new Image(pic_width ,pic_height);
pic6.src="myimg 6.gif";
pic7= new Image(pic_width ,pic_height);
pic7.src="myimg 7.gif";
pic8= new Image(pic_width ,pic_height);
pic8.src="myimg 8.gif";
}
var pics= new Array(8)
pics[0]=pic1.src;
pics[1]=pic2.src;
pics[2]=pic3.src;
pics[3]=pic4.src;
pics[4]=pic5.src;
pics[5]=pic6.src;
pics[6]=pic7.src;
pics[7]=pic8.src;
var numpics=8;
var thenum=0;
imgName="img1";
function change_it()
{
if (document.image s)
{
document.write( "<IMG SRC='"+pics[thenum]+"' border='0'
width='"+pic_wi dth+"' height='"+pic_h eight+"' name='img1'>\n" );
setTimeout('cha nge_it2()',dela y);
}
}
function change_it2()
{
var x=0;
thenum+=1;
if (thenum>numpics-1)
thenum=0;
document[imgName].src=pics[thenum];
x+=1;
setTimeout('cha nge_it2()',dela y);
}
</script>
then on my pages body i have
<SCRIPT language="JavaS cript" type="text/javascript">
<!--
change_it()
//-->
</SCRIPT>
Comment