Hi All,
I wonder if any Javascript experts can help me. I have the following code on my site which create a rotating graphic in the header every time the page loads. This works great.
However what I want to do is to change the way it works slightly so that I do not have to update the code in the future.
I would like to be able to put all the image address into a text file and then for the javascript to read them from there rather than hard codeing into the web page
or
for the javascript to read all the filenames from a directory of another server?
Is this possible and can anyone help me.
Many thank in advance.
#header {
background:#476 url("http://www.blogblog.com/rounders4/bg_hdr_bot.jpg") no-repeat left bottom;
margin:0 0 0;
padding:0 0 8px;
color:#fff;
}
Basically my script works by overwriting the 'background' definition at the <body> part of the template. I wrote the following right after the <body> tag:
<script type="text/javascript">
var banner= new Array()
banner[0]="http://static.flickr.com/84/269053449_acad87a793_o.jpg"
banner[1]="http://static.flickr.com/95/269053438_4ef5a3983e_o.jpg"
banner[2]="http://static.flickr.com/96/269053404_44a3b0eda8_o.jpg"
banner[3]="http://static.flickr.com/108/269053262_608edbdda4_o.jpg"
banner[4]="http://static.flickr.com/98/269053232_6f7c6f994a_o.jpg"
var random=Math.round(4*Math.random());
document.write("<style>");
document.write("#header {");
document.write(' background:url("' + banner[random] + '") no-repeat left TOP;');
document.write(" }");
document.write("</style>");
</script>