A
Alan Searle
I am a newby to javascript and would like to have a section on one page
where pictures change every 5 seconds.
I found some example sites which do what I want and I have tried to
'borrow' and adapt their source but without much luck.
In my tests I would just like two pictures (test1.gif and test2.gif) to
switch. I tried to assign these two to 'index_01' (see code below)
which should be loaded on startup.
In the code I cannot quite see how the 'index' links to the pictures
(and whether my naming is correct) and I am not sure how the timing is set.
Is there something I am missing? Is there other code that isn't present
in this source?
Maybe someone can take a quick look and tell me where I am going wrong
or can point me towards a good 'howto' (I have 'googled' on the
key-words but got swamped with garbage).
Thanks for any tips that you can give me.
Cheers,
Alan Searle
--------------------------------------------------
My skeleton test page ...
<HTML>
<HEAD>
<TITLE>Image Switch</TITLE>
<SCRIPT TYPE="text/javascript">
<!--
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}
var preloadFlag = false;
function preloadImages() {
if (document.images) {
index_01_test1 = newImage("images/index_01-test1.gif");
index_01_test2 = newImage("images/index_01-test2.gif");
preloadFlag = true;
}
}
// -->
</SCRIPT>
<!-- End Preload Script -->
</HEAD>
<BODY ONLOAD="preloadImages();">
<IMG NAME="index_01" SRC="images/index_01.gif" WIDTH=190 HEIGHT=143 ALT="">
</BODY>
</HTML>
where pictures change every 5 seconds.
I found some example sites which do what I want and I have tried to
'borrow' and adapt their source but without much luck.
In my tests I would just like two pictures (test1.gif and test2.gif) to
switch. I tried to assign these two to 'index_01' (see code below)
which should be loaded on startup.
In the code I cannot quite see how the 'index' links to the pictures
(and whether my naming is correct) and I am not sure how the timing is set.
Is there something I am missing? Is there other code that isn't present
in this source?
Maybe someone can take a quick look and tell me where I am going wrong
or can point me towards a good 'howto' (I have 'googled' on the
key-words but got swamped with garbage).
Thanks for any tips that you can give me.
Cheers,
Alan Searle
--------------------------------------------------
My skeleton test page ...
<HTML>
<HEAD>
<TITLE>Image Switch</TITLE>
<SCRIPT TYPE="text/javascript">
<!--
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}
var preloadFlag = false;
function preloadImages() {
if (document.images) {
index_01_test1 = newImage("images/index_01-test1.gif");
index_01_test2 = newImage("images/index_01-test2.gif");
preloadFlag = true;
}
}
// -->
</SCRIPT>
<!-- End Preload Script -->
</HEAD>
<BODY ONLOAD="preloadImages();">
<IMG NAME="index_01" SRC="images/index_01.gif" WIDTH=190 HEIGHT=143 ALT="">
</BODY>
</HTML>