Click to See Complete Forum and Search --> : checking if noather server is alive!


pelegk1
07-24-2003, 02:55 AM
i want to check if the page i reffer the user to is alive before i sent him there (which means at least i need to know that the server is alive!)
i want do avoid that the user will get a white page that the server not found and i want to show a warnning message of my own!
thanks in advance
Peleg

Nevermore
07-24-2003, 03:38 AM
You can either try to load an image/file from the server and see if it works, or you can ping them if you have a server side code.

pelegk1
07-24-2003, 03:44 AM
both of the ideas how to do it?
\i have server side script too
but can u give me code example for both of them so i figure out how to do it?
thanks in advance
pPeleg

man
07-24-2003, 07:45 AM
Originally posted by pelegk1
both of the ideas how to do it?
\i have server side script too
but can u give me code example for both of them so i figure out how to do it?
thanks in advance
pPeleg

Try this:

<script language="JavaScript">
Bild = new Image(); Bild.src = "http://xxx/your_gif_on server_here.gif";
var loop = 9, hoch = 24;
function Servertest()
{
if(Bild.height == hoch)
window.location.href="http://www.xxx.de/Go.htm";
else if (loop>0)
{loop--; window.setTimeout("Servertest()",1000);}
else
window.location.href="http://www.xxx.de/Stop.htm";
}
Servertest();
</script>

pelegk1
07-24-2003, 07:56 AM
but let me give u a tip :)
u dont need 9 loops
1 is enough withh 2 secon's delay
and the gif can be in size 1pixel*1pixel:)

pyro
07-24-2003, 08:48 AM
You can use onerror to check if the images loads (as cijori said)

<script type="text/javascript">

var img = new Image();
img.src = 'http://www.infinitypages.com/images/spacer.png';
img.onload = function () {document.getElementById("online").style.backgroundColor="#00ff00";}
img.onerror = function () {document.getElementById("online").style.backgroundColor="#ff0000";}

</script>

Server Status: <span id="online" style="width: 10px; height: 10px; background-color: transparent; font-size: 1px;"></span>Also, which server side language do you have? PHP?

pelegk1
07-24-2003, 09:09 AM
i have asp code
isnt't what u uggested it better then what cijori said!
beacuse u have a function to catch the error?

pyro
07-24-2003, 09:31 AM
Well, basically, what I did was impliment what cijori said. (Or at least I think that is what he was saying...) lol..

pelegk1
07-27-2003, 03:13 AM
function solution is the better solution for me

regards from israel - the land of peace
peleg