Swapping random flash banners

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="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="750"
height="95"><param name="movie"
value="sports_flash_header.swf"></object>');
flashHeader1= new Object();
flashHeader1.src = ('<object
classid="clsid:D27CDB6E-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="clsid:D27CDB6E-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="clsid:D27CDB6E-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>&copy; 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>
 
D

Dr John Stockton

JRS: In article <[email protected]>,
dated Fri, 3 Dec 2004 09:57:03, seen in Terry
Haufler said:
var time= new Date();
hours= time.getHours();
mins= time.getMinutes();
secs= time.getSeconds();
closeTime=hours*3600+mins*60+secs;

Better done with
closeTime = new Date().valueOf() / 1000 | 0
unless you do want rollback at midnight (add %86400), on plausible
assumptions about how you use it.

When posting code to News, do not allow your software to introduce line
breaks; it has the effect of making some of us not bother to read it.
Use two spaces, not a tab, as the indent unit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top