Time test

[Total: 0    Average: 0/5]

This has a timed test for 2 minutes then it will send you to another page.

Body Code:

<a href="javascript:settimes()">start timer</a>

<SCRIPT language=JavaScript>
function display()
{
	rtime=etime-ctime;
	if (rtime>60)
		m=parseInt(rtime/60);
	else
		m=0;

	s=parseInt(rtime-m*60);
	if(s<10)
		s="0"+s
	window.status="Time Remaining :  "+m+":"+s
	window.setTimeout("checktime()",1000)
}

function settimes()
{
	alert("You have 2 minutes to complete this test")
	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	etime=hours*3600+mins*60+secs;
	etime+=120;  
	/*
	You can change the value of 120 according to how much
	time you wish to set the timer. Where 120 is time in secs (120 = 2
	mins * 60 secs/min). Max time is 60 mins (3600secs)
	*/
	
	checktime();
}

function checktime()
{
	var time= new Date();
	hours= time.getHours();
	mins= time.getMinutes();
	secs= time.getSeconds();
	ctime=hours*3600+mins*60+secs
	if(ctime>=etime)
		expired();
	else
		display();
}

function expired()
{
	alert("Time expired");
	location.href="nextpage.html";  //Put here the next page
}

// -->
</SCRIPT>

This script gives the user 2 minutes to complete a test on this page before moving on to the next page. 
<br>Look at Window status

Times Viewed: 3

Leave a Reply

Your email address will not be published. Required fields are marked *