checking if server is online

H

hockese

Hello members!
I have 2 servers, on the first I have these code
<script type="text/javascript" src="http://server2/test.js"></script>
But if server2 is offline, it will take 30 seconds before timeout, I
found a script who can show images if server2 is online or off, is it
possible to change it so if server2 if offline nothing happens, and if
its online the http://server2/test.js is loaded?

Im so bad at javascript

Thanx in advance!




<html>
<head></head>
<body>
<img src="http://server2/Active.gif" name="mkraft">
<script language="JavaScript1.2">
var offlineImage = new Image();
offlineImage.src = "http://server1/inActive.gif";
var bufferImage = new Image();
bufferImage.onload = showEvent;
bufferImage.onerror = errorEvent;

function requestImage() {
bufferImage.src = "http://server2/Active.gif";
}

function showEvent() {
document.images['mkraft'].src = bufferImage.src;
setTimeout("requestImage()", 0);
}

function errorEvent() {
document.images['mkraft'].src = offlineImage.src;
setTimeout("requestImage()", 0);
}

requestImage();
</script>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top