T
Terry Haufler
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.setTimeout("Timer()",15000);
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="JavaScript" type="text/JavaScript">
<!--
var headerCount = 3
flashHeader0= new Object();
flashHeader0.src = ('<object
classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><param name="movie"
value="sports_flash_header.swf"></object>');
flashHeader1= new Object();
flashHeader1.src = ('<object
classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><param name="movie"
value="sports_flash_header_alt_gym.swf"></object>');
flashHeader2= new Object();
flashHeader2.src = ('<object
classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><param name="movie"
value="sports_flash_header_alt_volley.swf"></object>');
randomHeader= new Object();
function chooseHeader(){
randomNum = Math.floor((Math.random() * headerCount));
randomHeader = eval("flashHeader" + 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+secs;
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*3600+mins*60+secs;
if (curTime>=closeTime){
chooseHeader();
}
else{
// I don't understand why this line causes an "Object expected" error.
// window.setTimeout("Timer()",15000);
}
}
//-->
</script>
<link href="style_sheets/acp_style.css" rel="stylesheet"
type="text/css" />
</head>
<body background="images/elements/bg_grid.gif" leftmargin="0"
topmargin="5" bottommargin="5" marginwidth="0" marginheight="0"
onLoad="chooseHeader();">
<table width="750" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td>
<table width="752" border="0" cellpadding="0" cellspacing="0"
bgcolor="#FFFFFF">
<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="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
width="750" height="95">
<param name="movie"
value="sports_flash_header_alt_volley.swf">
<!--param name="quality" value="high"-->
<!--embed src="sports_flash_header_alt_volley.swf"
quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/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=flashHeader0.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.html">Terms of Use</a>
</h3>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
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.setTimeout("Timer()",15000);
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="JavaScript" type="text/JavaScript">
<!--
var headerCount = 3
flashHeader0= new Object();
flashHeader0.src = ('<object
classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><param name="movie"
value="sports_flash_header.swf"></object>');
flashHeader1= new Object();
flashHeader1.src = ('<object
classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><param name="movie"
value="sports_flash_header_alt_gym.swf"></object>');
flashHeader2= new Object();
flashHeader2.src = ('<object
classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><param name="movie"
value="sports_flash_header_alt_volley.swf"></object>');
randomHeader= new Object();
function chooseHeader(){
randomNum = Math.floor((Math.random() * headerCount));
randomHeader = eval("flashHeader" + 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+secs;
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*3600+mins*60+secs;
if (curTime>=closeTime){
chooseHeader();
}
else{
// I don't understand why this line causes an "Object expected" error.
// window.setTimeout("Timer()",15000);
}
}
//-->
</script>
<link href="style_sheets/acp_style.css" rel="stylesheet"
type="text/css" />
</head>
<body background="images/elements/bg_grid.gif" leftmargin="0"
topmargin="5" bottommargin="5" marginwidth="0" marginheight="0"
onLoad="chooseHeader();">
<table width="750" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td>
<table width="752" border="0" cellpadding="0" cellspacing="0"
bgcolor="#FFFFFF">
<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="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
width="750" height="95">
<param name="movie"
value="sports_flash_header_alt_volley.swf">
<!--param name="quality" value="high"-->
<!--embed src="sports_flash_header_alt_volley.swf"
quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/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=flashHeader0.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.html">Terms of Use</a>
</h3>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>