PDA

View Full Version : Veryifing A Link is available


pastorOfMuppets
07-02-2002, 03:29 AM
Hi,

I want to be able to have an image or some text (either will be fine) to show wether or not my home server is online. I want visitors to my website to be able to see wether or not my server at home is online, so they know wether or not they can download from me. I have created an image file that sits on my server saying that i am online, and this shows on the website when the server is online, but when it is offline, the image does not display .

Anyideas on how i can verify if a link works?

Thanks a lot

pastorOfMuppets
07-02-2002, 06:42 AM
hmm no responses :D , Does anyone think that this is outside the range of Javascript?:D

Thanks all!

jkd
07-02-2002, 06:46 AM
<img src="http://someip/serverup.gif" alt="Server status" onerror="alert('Server down!')"/>

pastorOfMuppets
07-02-2002, 06:49 AM
Thnks JKD

jalarie
07-02-2002, 03:40 PM
To JKD: That seems to work rather well if the server is down the first time I try it, but what if it was once up, the image was cached, and the server is now down? :confused:

joh6nn
07-02-2002, 04:19 PM
try this:

<script>
var timeout;
function online() {
document.images['status'].onerror = 'path/to/offline.gif';
document.images['status'].src = 'path/to/online.gif';
setTimeout('online();', 30000);
}

window.onload = function() { setTimeout('online();', 30000);
}
</script>

<IMG NAME="status" SRC="about:blank;">

didn't test it at all, but in theory, that will check if your server is online every 5 minutes, and update the picture accordingly. also, instead of alerting, it loads another picture into your image tag, if you're offline.

Quiet Storm
07-02-2002, 05:20 PM
WOW! That's cool! Gives me some new ideas... :)

whammy
07-03-2002, 12:08 AM
I've just got to add:

pastorOfMuppets is a very cool name... heheh ;)

Sounds like a Wierd Al "Metallica Parody" Album... LOL

/me sings:

"pastorOfMuppets is preaching to me... frogs can't go out with Miss Piggy... blinded by love it don't mean a thing... he just doesn't buy a cross-species ring... pastor! pastor!"

Hehehe...

pastorOfMuppets
07-03-2002, 01:38 AM
thanks to all the others for posting ideas, (espically the ones that have got something to do with the topic)

thanks!