spowell_40
03-09-2004, 01:35 PM
Ok, I am trying to display an image on my page that is different everytime I reload the page (or at least random). Here is the script I have so far:
In my header:
<script language="JavaScript" src="imgRotate.js" type="text/javascript"></script>
In my body:
<script language="JavaScript" type="text/javascript">
<!-- document.write('<img src="images.htm'+imgArray[randNum]+'" width="750" height="228" alt="The Official Site of the Kentucky Weightlifting Committee" border="0">');
//-->
</script>
Here is the src for imgRotate.js:
//IMAGE ROTATE SCRIPT
var imgArray = new Array();
//Place image names here:
imgArray[0] = "backgroundimage_1.jpg";
imgArray[1] = "backgroundimage_2.jpg";
var numImgs=imgArray.length;
var randNum = Math.floor(Math.random() * numImgs);
and finally, my images htm page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Index of /images</TITLE>
</HEAD>
<BODY>
<H1>Index of /images</H1>
<PRE><ALT=" "> <A HREF="?N=D">Name</A> <A HREF="?M=A">Last modified</A> <A HREF="?S=A">Size</A> <A HREF="?D=A">Description</A>
<HR>
<ALT="[IMG]"> <A HREF="background_1.jpg">background_1.jpg</A> 08-Mar-2004 14:15 1k
<ALT="[IMG]"> <A HREF="background_2.jpg">background_2.jpg</A> 08-Mar-2004 14:15 1k
</PRE></HR>
</BODY></HTML>
Now, it should do what I am trying to get it to do, and yet it won't. What's going on? If necessary I will upload these to the web to make viewing easier. Thanks.
-Scott P.
In my header:
<script language="JavaScript" src="imgRotate.js" type="text/javascript"></script>
In my body:
<script language="JavaScript" type="text/javascript">
<!-- document.write('<img src="images.htm'+imgArray[randNum]+'" width="750" height="228" alt="The Official Site of the Kentucky Weightlifting Committee" border="0">');
//-->
</script>
Here is the src for imgRotate.js:
//IMAGE ROTATE SCRIPT
var imgArray = new Array();
//Place image names here:
imgArray[0] = "backgroundimage_1.jpg";
imgArray[1] = "backgroundimage_2.jpg";
var numImgs=imgArray.length;
var randNum = Math.floor(Math.random() * numImgs);
and finally, my images htm page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Index of /images</TITLE>
</HEAD>
<BODY>
<H1>Index of /images</H1>
<PRE><ALT=" "> <A HREF="?N=D">Name</A> <A HREF="?M=A">Last modified</A> <A HREF="?S=A">Size</A> <A HREF="?D=A">Description</A>
<HR>
<ALT="[IMG]"> <A HREF="background_1.jpg">background_1.jpg</A> 08-Mar-2004 14:15 1k
<ALT="[IMG]"> <A HREF="background_2.jpg">background_2.jpg</A> 08-Mar-2004 14:15 1k
</PRE></HR>
</BODY></HTML>
Now, it should do what I am trying to get it to do, and yet it won't. What's going on? If necessary I will upload these to the web to make viewing easier. Thanks.
-Scott P.