<html>
<head>
<script type="text/javascript">
function GetXmlHttpObject()
{
var xmlHttp = null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function twoChars(getal)
{
return (getal < 10) ? '0' + getal: getal;
}
function Countdown(id, totalSec, href, text)
{
if ( totalSec == 0)
{
Request(id, true, href, text);
return true;
}
if ( totalSec > 0 )
{
innerHTML = twoChars( Math.floor( (totalSec % 3600) / 60) ) + ':' + twoChars( totalSec % 60 );
if (totalSec >= 3600)
{
innerHTML = twoChars( Math.floor(totalSec / 3600)) + ':' + innerHTML;
}
totalSec--;
setTimeout("Countdown('" + id + "', " + totalSec + ", '" + href + "', '" + text + "')", 1000);
document.getElementById(id).innerHTML= innerHTML;
}
return true;
}
function Request(id, change, href, text)
{
if (change = true)
{
document.getElementById(id).innerHTML = '<a href="' + href + '">' + text + '</a>';
}
document.getElementById('text').innerHTML = document.getElementById('text').innerHTML + 'boe!<br />';
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="ajax.php";
url=url+"?id="+id;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
function stateChanged()
{
if(xmlHttp.readyState == 4)
{
if( xmlHttp.responseText > 0)
{
Countdown(xmlHttp.id, xmlHttp.responseText, xmlHttp.href, xmlHttp.text);
document.getElementById('text').innerHTML = document.getElementById('text').innerHTML + xmlHttp.responseText + ' - done!<br />';
return true;
}
setTimeout("Request('" + xmlHttp.id + "', false, '" + xmlHttp.href + "', '" + xmlHttp.text + "')", 1000);
}
}
window.onload = function()
{
Countdown('test', 6, 'http://www.criminalspoint.net', 'CP');
}
</script>
</head>
<body>
<div id="test"></div>
<br />
<div id="text"></div>
</body>
</html>
Toon Meer
Is dit genoeg voorgekauwd?
Inderdaad het doet het nog niet...
maar het geeft je wel een idee van hoe het zou kunnen...
succes met zorgen dat het werkt...
ik heb al te veel gedaan eigenlijk...