472,145 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

Swapping random flash banners

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>
Jul 23 '05 #1
1 5167
JRS: In article <7b**************************@posting.google.com >,
dated Fri, 3 Dec 2004 09:57:03, seen in news:comp.lang.javascript, Terry
Haufler <te**********@acplus.com> posted :
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.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Virus | last post: by
reply views Thread by DDK | last post: by
1 post views Thread by sven.daems | last post: by
1 post views Thread by Kal | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.