Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use getDate to show different html pages?

Status
Not open for further replies.

PS1983

Technical User
Nov 6, 2001
83
AT
hi there!
can i use getDate to show different pages?

hours and minutes doesn't matter, but the seconds

0-19 -->html 1
20-39 -->html 2
40-59 -->html 3

is this possible? or is there another possibillity to view different pages everytime page is refreshed?

every help is really appreciated

thx
 
Hey, thanks for that code for that back button thing, hope this will help you.

It can open a page every x seconds, but if you open a page with this code that tries to open another page something doesnt work ... sure you can figure it out.

Its just a little bit messy :)

<HTML>
<HEAD>
</HEAD>
<body onLoad=&quot;time_spent()&quot; >
<SCRIPT language=JavaScript>
<!--
var startDate = new Date();
var startTime = startDate.getTime();

// THIS FUNCTION CALCULATES THE SECONDS ELAPSED SINCE THE PAGE WAS LOADED
function seconds_elapsed () {
var date_now = new Date ();
var time_now = date_now.getTime ();
var time_diff = time_now - startTime;
var seconds_elapsed = Math.floor ( time_diff / 1000 );

// NB NB change the second argument for window.open , because if a window is open
// with the same value as one you are trying to open it doesnt open.

if (seconds_elapsed == 2) {
winpopup = window.open('test2.html','popup2','height=500,width=400,screenX=100,screenY=0,left=100,top=0');
}
if (seconds_elapsed == 4) {
winpopup = window.open('test2.html','popup4','height=500,width=400,screenX=100,screenY=0,left=500,top=0');
}
if (seconds_elapsed == 6) {
winpopup = window.open('test2.html','popup6','height=500,width=400,screenX=100,screenY=0,left=100,top=500');
}
if (seconds_elapsed == 8) {
winpopup = window.open('test2.html','popup8','height=500,width=400,screenX=100,screenY=0,left=500,top=500');
}
if (seconds_elapsed == 10) {
winpopup = window.open('test2.html','popup10','height=500,width=400,screenX=100,screenY=0,left=250,top=250');
}

// window.close();
return ( seconds_elapsed );
}

// THIS FUNCTION TAKES THE SECONDS ELAPSED AND CONVERTS THEM FOR OUTPUT
function time_spent () {
// TAKE THE SECONDS ELAPSED
var secs = seconds_elapsed ();
// CONVERT SECONDS TO MINUTES AND SECONDS
var mins = Math.floor ( secs / 60 );
secs -= mins * 60;
// CONVERT MINUTES TO HOURS AND MINUTES
var hour = Math.floor ( mins / 60 );
mins -= hour * 60;
// DISPLAY THE FINAL OUTPUT TIME STRING
document.display.timeElapsed.value = pad ( hour ) + &quot;:&quot; + pad ( mins ) + &quot;:&quot; + pad ( secs );
// RECURSIVELY RE-RUN THE FUNCTION EVERY SECOND
setTimeout( &quot;time_spent ()&quot;, 1000 );
}

// THIS FUNCTION INSERTS A LEADING ZERO (IF NECESSARY) TO PROVIDE UNIFORM OUTPUT
function pad ( num ){
return ( ( num > 9 ) ? num : &quot;0&quot; + num );
}
-->
</SCRIPT>

<form name=&quot;display&quot;>
<input name=&quot;timeElapsed&quot; type=&quot;text&quot; size=8>
</form>
</BODY>
</HTML>
 
no problem damian!

glad i helped you

thx for your response too, i will take a look at it, seems to be helpful thx you!
 
found a simple solution look at this!

<script language=&quot;JavaScript1.2&quot;>
<!--

function shiftsource()
{
now=new Date();
Sekunden = now.getSeconds();
if (Sekunden < 20) window.location.href=&quot;flash1.html&quot;;
if (Sekunden > 19 && Sekunden < 40) window.location.href=&quot;flash2.html&quot;;
if (Sekunden > 39) window.location.href=&quot;flash3.html&quot;;
}

// -->
</script>


brilliant huh? a friend of me made it in 5 minutes!!

jeah i think it rocks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top