I am trying to swap/rotate random flash banners using the following
Javascript code. I have 3 flash headers/banners. I can get it to
open a page with a random header using document.write( randomHeader) in
the chooseHeader() function, but the rest of the page doesn't get
displayed with that approach.
Instead, what I would like to do is comment the
document.write( randomHeader) line, and use the random reference I have
in the table cell towards the bottom of the file.
Also, the setTimeout method in the Timer() function produces an
"Object expected" error. I've tried giving it more time, to no avail.
window.setTimeo ut("Timer()",15 000);
Could someone point out corrections I need to make, or alternate
solutions (using Javascript)?
Thank you, Terry
<html>
<head>
<title>ACP - Healthcare/Long Term Care : About our Company</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<script language="JavaS cript" type="text/JavaScript">
<!--
var headerCount = 3
flashHeader0= new Object();
flashHeader0.sr c = ('<object
classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><pa ram name="movie"
value="sports_f lash_header.swf "></object>');
flashHeader1= new Object();
flashHeader1.sr c = ('<object
classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><pa ram name="movie"
value="sports_f lash_header_alt _gym.swf"></object>');
flashHeader2= new Object();
flashHeader2.sr c = ('<object
classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><pa ram name="movie"
value="sports_f lash_header_alt _volley.swf"></object>');
randomHeader= new Object();
function chooseHeader(){
randomNum = Math.floor((Mat h.random() * headerCount));
randomHeader = eval("flashHead er" + randomNum + ".src");
document.write( randomHeader);
startTime();
}
function startTime(){
var time= new Date();
hours= time.getHours() ;
mins= time.getMinutes ();
secs= time.getSeconds ();
closeTime=hours *3600+mins*60+s ecs;
closeTime+= 15; // How many seconds til the next rotation
Timer();
}
function Timer(){
var time= new Date();
hours= time.getHours() ;
mins= time.getMinutes ();
secs= time.getSeconds ();
curTime=hours*3 600+mins*60+sec s;
if (curTime>=close Time){
chooseHeader();
}
else{
// I don't understand why this line causes an "Object expected" error.
// window.setTimeo ut("Timer()",15 000);
}
}
//-->
</script>
<link href="style_she ets/acp_style.css" rel="stylesheet "
type="text/css" />
</head>
<body background="ima ges/elements/bg_grid.gif" leftmargin="0"
topmargin="5" bottommargin="5 " marginwidth="0" marginheight="0 "
onLoad="chooseH eader();">
<table width="750" border="0" align="center" cellpadding="0"
cellspacing="0" >
<tr>
<td>
<table width="752" border="0" cellpadding="0" cellspacing="0"
bgcolor="#FFFFF F">
<tr>
<td width="1" rowspan="7" align="left" valign="top"
background="var/www/html/newsite/images/elements/pxl_black.gif">
<img width="1" height="100%" />
</td>
<td>
<img src="images/elements/pxl_black.gif" width="750"
height="1" />
</td>
<td width="1" rowspan="7" align="left" valign="top"
background="var/www/html/newsite/images/elements/pxl_black.gif" />
</tr>
<!--tr>
<td width="750" height="95" align="left" valign="top">
<img name="banner" border="0" />
</td>
</tr-->
<!--Single reference works fine (when document.write in chooseHeader()
is commented): -->
<!--tr>
<td>
<object classid="clsid: D27CDB6E-AE6D-11cf-96B8-444553540000"
width="750" height="95">
<param name="movie"
value="sports_f lash_header_alt _volley.swf">
<!--param name="quality" value="high"-->
<!--embed src="sports_fla sh_header_alt_v olley.swf"
quality="high" pluginspage="ht tp://www.macromedia. com/go/getflashplayer"
type="applicati on/x-shockwave-flash" width="750"
height="95"></embed-->
</object>
</td>
</tr-->
<!--This random reference is what I want to use (when document.write
in chooseHeader() is commented): -->
<tr>
<td width="750" height="95" align="left" valign="top">
<embed name="movie" border="0" />
<embed src=flashHeader 0.src border="0" />
</td>
</tr>
<tr>
<td width="750">
<div align="center">
<h3>© 2000-2004 Accelerated Care Plus Corporation, All
Rights Reserved <a href="terms.htm l">Terms of Use</a>
</h3>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>