I didn't have the time to complete the script, like I want it,
and will over the weekend be away anyway,
so I'm basically posting to thank mocker first for his great advice and
dense solution about the random image. I wanted at first
to try to embed in the script a random number generator like
the following:
function rand(n) {
return ( Math.floor ( Math.random ( ) * n ) );
}
but this is now obsolete. On the other hand I've got still
the impression that at the beginning of every rotation, there is a
slight delay, so I embedded the preloading feature from the first
script above, it seems that things are now loading smoother,
or is this only my impression or my imagination that
is deceiving me, I'm not sure?
The script looks right now as:
CODE
<script>
var bgimage=new Array()
bgimage[0]="image1.png"
bgimage[1]="image2.png"
bgimage[2]="image3.png"
bgimage[3]="image4.png"
//feature preloading images
var processing=new Array()
for (i=0;i<bgimage.length;i++){
processing[i]=new Image()
processing[i].srd=bgimage[i]
}
var abc=-1
var divID = 'te';
function t(){
if (abc<bgimage.length-1)
abc++
else
abc=0
document.body.background=processing[Math.floor(Math.random()*bgimage.length)].srd
document.getElementById(divID).style.background = 'url("'+bgimage[abc]+'")'; //or for random
image change of the div background replace with: 'url("'+ bgimage[Math.floor(Math.random()*bgimage.length)]+'")'; and/or for rotating change of images
for the body backgroung replace appropriate with: processing[abc].srd
}
window.onload = load;
function load()
{
setInterval("t()",2000); //change every 2 seconds, can be
changed.
}
</script>
<style>
#te{
background-image: url(NORMAL_BG_IMAGE_URL_HERE);
}
</style>
<div id="te">
TEst
</div>
<br />
<input type="button" onclick="t()" />
but there seems to be a problem/conflict with an other
script that I am using for sliding through the pictures, both don't
seem to work at the same time when they are together,and
I thought that maybe I could modify the above script to do
the work of the other script too, i.e. to change not only
the background picture (randomly and/or rotating) of a div and/or
the whole body section, but also to show the pictures
in a other div, not as background but as a random or
rotating slide show of the pictures, linking every one of them
also to an url. I don't know if these is difficult/possible, or if it is
better to use two separated scripts, but then, how to solve
the conflicts of the two I am using, so that both do work?
Thanks for any help
St