Click to See Complete Forum and Search --> : Thank god its Friday!


alexthomas
02-26-2003, 08:05 AM
Hi all.

I have a problem. right...

I have a page that contains a loop that calls in a different page every six seconds. i.e.

Page1 - 0secs
Page2 - 6secs
Page3 - 12secs

Then after 18 seconds the counter is reset to zero and the pages are loaded again, fine that works.

What I would like to do is, if the day is Friday it loads a completely different page i.e. Friday.htm. I had it working, but you had to reload the page for it to work, however this is not suitable, as it will be running on a machine with no interaction. Therefore I think I need to incorporate it into my loop so that it checks it every time the loop begins, and if its Friday display Friday.htm, and if its not continue with the page1,2,3 loop.

I thought this would be pretty straightforward with the use of if/else statements, but my knowledge is very limited so, I’m not sure if this is right.

Can anyone help me please? :)

Thanks in advance

Al

P.s.

Here is the code so far:

<html>
<head>
<title> Frame 1a </title>
<script language="JavaScript">
var first = true;
function init() {
if (first)
{first = false;
setInterval("init()", 18 * 1000);}
setTimeout("window.main.location.href = 'frame1a.htm'", 0 * 1000);
setTimeout("window.main.location.href = 'frame1b.htm'", 6 * 1000);
setTimeout("window.main.location.href = 'frame1c.htm'", 12 * 1000);
}
</script>
</head>
<frameset rows="100%,*" border=0 onload="init()">
<frame name="main" src="0.htm" scrolling="no" noresize>
</frameset>
</html>

dabush
02-26-2003, 09:04 AM
<html>
<head>
<script language=JavaScript>
<!--
function init()
{
var date = new Date();
var day = date.getDay();
if (day == 5)
{
friday();
}
else
{
window.main.location.href = "frame1a.htm";
setTimeout("window.main.location.href='frame1b.htm'",6000);
setTimeout("window.main.location.href='frame1c.htm'",1200);
}
setTimeout("init();",1800);
}
function friday()
{
window.main.location.href = "Friday.htm";
}
// -->
<script>
</head>
<frameset rows="100%,*" border=0 onLoad="init();">
<frame name=main src=0.htm scrolling=no resize>
</frameset>
</html>

alexthomas
02-26-2003, 09:12 AM
Thanks but,

That didn't work buddy. I just got a blank frame.

:confused:

dabush
02-26-2003, 12:06 PM
i messed it up, but this DOES work.


<html>
<head>
<script language=JavaScript>
<!--
var frame_array = new Array();

frame_array[0] = "frame1a.htm";
frame_array[1] = "frame1b.htm";
frame_array[2] = "frame1c.htm";

var frame_count = -1;
function init()
{
var date = new Date();
var day = date.getDay();
if (day == 5)
{
friday();
}
else
{
frame_count++;
if (frame_count >= frame_array.length) frame_count = 0;
window.main.location.href = frame_array[frame_count];
}
setTimeout("init();",6000);
}
function friday()
{
window.main.location.href = "Friday.htm";
}
// -->
</script>
</head>
<frameset rows="100%,*" border=0 onLoad="init();">
<frame name=main src=0.htm scrolling=no noresize>
</frameset>
</html>