Scripting: JS Reload Question

started by Primerdp on May 31, 2005 — RSS Feed

Primerdp Primerdp
Posts: 3

Sorry, I didn't mean to post this twice... I posted it in Markup first, which is the wrong section. Nonetheless, here's the question:

Here's a problem I'm trying to solve. Instead of having the image change on every reload, I'd like the image to reload every so many seconds. To add in a little extra challenge, it's also supposed to update the link simultaneously. Is this possible? This is what I'm trying to accomplish:

a href="page1.htm" .. img src="img1.gif"
then 15 seconds later....
a href="page2.htm" .. img src="img2.gif"
then 15 seconds later.....
a href="page3.htm" .. img src="img3.gif"
loop back 15 seconds later.....
a href="page1.htm" .. img src="img1.gif"

How would I go about doing this?

Thank you!

Primerdp Primerdp
Posts: 3

Ok, I looked around the site for awhile and found some help. Is there any way to make this code work in time intervals? (instead of only working when you refresh)

<html>
<head>
<title>jadsf</title>
<script>
<!--
var max=3;
var thisBanner=1;
var banner=new MakeBannerArray(max);

function MakeBannerArray(n)
{
     this.length=n;
     for (var i=1; i<=n;i++)
           {
           this="";
           }
     return this;
}

banner[1]='<a href="1"><img src="--- path to image file ---" width="468" height="60" border="0" alt="1"></a>';
banner[2]='<a href="2"><img src="--- path to image file ---" width="468" height="60" border="0" alt="2"></a>';
banner[3]='<a href="3"><img src="--- path to image file ---" width="468" height="60" border="0" alt="3"></a>';

function rand(n)
     {
     rnum=Math.floor(n*Math.random())+1;
     return rnum;
     }

function setBanner()
     {
     thisBanner=rand(max);
     }


//-->
</script>
</head>
<body>
<script type="text/javascript" language="JavaScript">
<!--
setBanner();
document.write (banner[thisBanner]);
// -->
</script>
</body>
</html>

You must login to reply