473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Preload images still reloading from server?

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="JavaScript" 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.images)
{
pic1= new Image(pic_width,pic_height);
pic1.src="myimg1.gif";
pic2= new Image(pic_width,pic_height);
pic2.src="myimg2.gif";
pic3= new Image(pic_width,pic_height);
pic3.src="myimg3.gif";
pic4= new Image(pic_width,pic_height);
pic4.src="myimg4.gif";
pic5= new Image(pic_width,pic_height);
pic5.src="myimg5.gif";
pic6= new Image(pic_width,pic_height);
pic6.src="myimg6.gif";
pic7= new Image(pic_width,pic_height);
pic7.src="myimg7.gif";
pic8= new Image(pic_width,pic_height);
pic8.src="myimg8.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.images)
{
document.write("<IMG SRC='"+pics[thenum]+"' border='0'
width='"+pic_width+"' height='"+pic_height+"' name='img1'>\n");
setTimeout('change_it2()',delay);
}
}

function change_it2()
{
var x=0;
thenum+=1;

if (thenum>numpics-1)
thenum=0;

document[imgName].src=pics[thenum];
x+=1;
setTimeout('change_it2()',delay);

}
</script>
then on my pages body i have
<SCRIPT language="JavaScript" type="text/javascript">
<!--
change_it()
//-->
</SCRIPT>
Jul 20 '05 #1
2 1637
DiggidyMack69 wrote:
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?


You could try the following:
....
var pics= new Array(8)
pics[0]=pic1;
pics[1]=pic2;
// Etc.
....
function change_it() {
......
document.write("<IMG SRC='"+pics[thenum].src+"' ...Etcetera

....
function change_it2() {
.......
document[imgName].src=pics[thenum].src;
HTH,
JW

Jul 20 '05 #2
"Janwillem Borleffs" <jw@jwscripts.com> wrote in message news:<3f***********************@news.wanadoo.nl>.. .
DiggidyMack69 wrote:
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?


You could try the following:
...
var pics= new Array(8)
pics[0]=pic1;
pics[1]=pic2;
// Etc.
...
function change_it() {
.....
document.write("<IMG SRC='"+pics[thenum].src+"' ...Etcetera

...
function change_it2() {
......
document[imgName].src=pics[thenum].src;
HTH,
JW


Sorry, but I don't see how that is different than what I have already??
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Perttu Pulkkinen | last post by:
I use database to store images. So img-tags are like <img src="viewer.php?img_id=100"> Can I use javascript/php-combination to preload images of whole site after first page is loaded? Or does...
7
by: MALdito | last post by:
hi everybody let me say right from the start .. I´m not a coder ... "just" a designer! that said .. here is my question: I´m using dreamweaver´s built in preloader for a menu. it looks like...
11
by: Michel | last post by:
Here is a litle script that preload images and show a thumbnail. Once you get on the picture you see the real size It worsk fine with normal picture but when the url has some parameters like in...
3
by: Bob | last post by:
I usually use some "pre-load" code in my pages to preload graphics that will be swapped. But, I'm thinking that rather than the long, repetitive, once, for each graphic hardcoded stuff like this: ...
2
by: Albert Spencil | last post by:
I have tried several preload scripts found here; plus, some of my own. The only thing that works is the unsophisticated loading of those tiny images. The download consist of 100+ images amounting...
1
by: Stacey | last post by:
Hi, I'm hoping for a bit of advise-- I have a (relatively, from the point-of-view of this dilettante) complex script that attempts to preload certain images in order to trigger one of a series of...
3
by: Matthew Crouch | last post by:
okay, i've got a server-side (php) script creating a bunch of JS image vars in a loop .. {{foreach from=$button_names_array key=key item=button_name}} var {{$button_name}}_up = new...
1
by: ks | last post by:
HI is it possible to preload images to client browser directly from sql server without storing them on server space Have a nice day thanks in advance ks.
4
by: shapper | last post by:
Hello, I think to preload an image I should us something like: img = new Image(); img.src = 'images/img.jpg'; Could someone tell me how to create a loop which would preload a list of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.