Click to See Complete Forum and Search --> : Pages freeze when server is down.


Oneill
01-08-2003, 10:14 AM
Hi,

Does anybody know how to prevent the browser from hanging when a Javascript references a script on a remote server, in the case when the remote server is unavailable or down.

For example, we offer the following script as a free service, but if our server is down or isolated from the network, then the script not only ceases to operate, but blocks the loading of the entire page that it is on.

// To display the national flag of
// the viewer's country.
<script language="Javascript" src="http://map.geoup.com/geoup?template=flag"></script>

What would be really cool, would be if we could fail gracefully or load the script src from an alternate server. As a minimum, we would like to at least be able to let the page continue loading.

BTW, I am not sure if it is relevant or not, but the script does not always load an image, as in the flag above, it can also be used to return a phrase - as in
<script language="Javascript" src="http://map.geoup.com/geoup?template=welcome"></script>
which displays a localized welcome message which refers to the viewers city.

Any ideas?

Kind Regards
Russell Turner
Geobytes, inc.
http://www.geobytes.com/
Geobytes - because everybody's somewhere!

BestZest
01-08-2003, 02:35 PM
I don't know if this will work but you could try the 'onError' event handler.

BestZest

Oneill
01-23-2003, 08:36 AM
Thanks BestZest for your reply earlier, sorry i couldnt have said that sooner. We had already considered using onError, however I am told we cannot use this to overcome our problem, I think last I checked they were tinkling with some way of contacting the server to make sure it is there, or something... thanks for your suggestion though any suggestions are great.

khalidali63
01-23-2003, 12:03 PM
If you are not using any other server side programming language then using only JavaScript actually limits your ability to ping a server in any way.

In NS6+/mozilla1+ browsers you can use LiveConnect to call Java classes and have them take care of some thing like this.

Other then that I think you will have to resort to image.onError event,
and by the way it works prety good if it is used properly.

cheers

Khalid

HiMyNameIs
08-30-2003, 04:50 PM
Can anyone provide insight on this problem? We're now having the same issue.

Khalid Ali
08-31-2003, 06:19 AM
well here is an option,it does work,however will it fit in your problem thats completely up to you to see..:-)

http://www.webapplikations.com/pages/html_js/document/FindOutAServerIsUp.html