Witam! Znalazłem gdzieś taki oto skrypt, i chciałbym go troszkę przerobić.
Tzn. żeby przekierowanie nastąpiło po 20 sek. a nie 30 sek., oraz jak przekierować na inną domenę, bo
<?php
makeRequest("http://testowa-domena.pl");
?>
nie działa w tym skrypcie poniżej...
<?php
<html>
<head>
<title>www.test.pl</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2" >
<script language="javascript">
var timerID = null;
var timerRunning = false;
var timer_org = 30;var timerAktual = 30;var limit = true;var blokada = false;function stopclock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false;
}
function startclock()
{
stopclock();
showtime();
}
function showtime()
{
if(!blokada)
{
document.clock.face.value = timerAktual;
timerAktual--;
if(timerAktual<0)
{
makeRequest("http://testowa-domena.pl");
timerAktual=timer_org;
}
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
}
var http_request = false;
function makeRequest(url)
{
url
= url
+ "?tstamp="+new Date(); http_request = false;
if (window.XMLHttpRequest)
{ // Mozilla, Safari,...
http_request = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{ // IE
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
}
}
}
if (!http_request)
{
alert('Błąd inicjalizacji');
return false;
}
http_request.onreadystatechange = function() { alertContents(http_request); };
http_request.open('GET', url, true);
http_request.send(null);
}
function alertContents(http_request)
{
//alert(http_request.responseText);
if (http_request.readyState == 4)
{
if (http_request.status == 200)
{
if(http_request.responseText == '0')
{
window.location = "http://www.test.pl";
}
else
{
if(limit == true)
{
window.location = "http://www.test.pl";
}
else
{
//document.kolejka.numer.value = http_request.responseText;
}
}
}
else if ((http_request.status == 408) || (http_request.status == 404) || (http_request.status == 503) || (http_request.status == 400))
{
window.location = "http://www.test.pl";
}
}
}
//-->
</script>
<style>
.infoBoxContents {
background: #ffc000;
font-family: Verdana;
font-size: 10px;
}
.tabela {
background: #fffcd6;
font-family: Verdana;
font-size: 13px;
}
</style>
</head>
<form name="clock" onSubmit="0">
<br>
<font size = 4>Automatycznie strona odświeży się za
<input type="text" name="face" size="1" style="text-align:center;border:0;background:rgb(255,252,214);font-size:18px">
sekund.
</font>
</form>
</font>
<script>startclock();</script>
</td>
</tr>
</tbody>
</table>
</body>
</html>
?>
Ten post edytował przemasisko 23.02.2008, 16:32:40