473,322 Members | 1,425 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 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 5255
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ann | last post by:
Hi all, Is it possible to have flash banners in headers and in the pages of a plone site..I have downloaded CMFFlashMovie 0.3.2. I can upload(add flashcontent) on a page by itself on the plone...
10
by: Virus | last post by:
Ok well what I am trying to do is have 1.) the background color to change randomly with 5 different colors.(change on page load) 2,) 10 different quotes randomly fadeing in and out in random...
0
by: DDK | last post by:
Does anyone know if the asp.net adrotator control supports flash banners. If so, how does the XML file look with a flash banner in it. I am trying to get a .swf flash file to work with the...
1
by: sven.daems | last post by:
Hy I want to add a sort of news service to my site. I've a number of messages, wich I want to be shown in a <marquee> tag. I've found a simple scrit that generates an random message (wich I've...
2
by: Crash44 | last post by:
This is driving me quite nuts. I have created several flash banners for a record label. They are meant to link to an artist splash page. Simple enough, right? Both Mac and PC users can click on...
1
by: Kal | last post by:
Hi everyone, I have a simple sight that has a unique flash banner for every button of my navigation. so my navigation looks something like this (home, services, location, etc..) when a user...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.