Saturday, March 17, 2007

Simple way to check if a Domino Server is online

This is a small one, but I thought it was a nice example how nice and powerful events in JavaScript are.

The images (<img> tag) on the web has an onerror-event that fires if the image in the src is either an invalid image, or the image is not found (404). Every Domino server has an icons-folder. The most used icon/image is ecblank.gif, which Notes uses in many nasty ways on the web.

To check if a notes-server is online, you simply make an image tag with src=http://serverdomain.com/icons/ecblank.gif
onerror, change some text, pop an alertbox up etc.

In my simple demo, I add a css class to a a div, and replace() innerHTML with a status.

Demo (view source to see how it is done)

If you want to automate the testing of online-status on your company's servers, you can use the Windows API's UrlDownloadToFile ( example ) to download ecblank.gif. OnError - log error, send mail etc.

3 comments:

Thomas Adrian said...

Nice One, thank you


Thomas
http://www.notessidan.se

William Beh said...

Besides checking the status of the server, you can use the blank.gif to keep a http session alive with domino
[link]

Dwight Wilbanks said...

This does not appear to be what was expected.
[img
src="http://www.ibm.com/icons/ecblank.gif"
onload="online('codestore')"
onerror="offline('codestore')"/]

But, its a good idea. I've been meanign to use the onerror event of an image for some time, I've assumed that it would work, I just have not had a need to do it.

My thought was that I might be able to switch to mirror servers if off loading images, or something like that.