Redirect browser only if a web site is available

I have an HTML file stored on the local file system. I need it to redirect (or otherwise display in some fashion) a remote web site ONLY if the site is online and available. If the site is not available, I need to display a user-friendly message.Currently I have: Connecting to remote server… The problem is that if …

via HTML Language Development » Search Results » ajax:

Redirect browser only if a web site is available

I have an HTML file stored on the local file system. I need it to redirect (or otherwise display in some fashion) a remote web site ONLY if the site is online and available. If the site is not available, I need to display a user-friendly message.
Currently I have:

Connecting to remote server…


The problem is that if the server is unavailable, the user is presented with an ugly “can’t find server” page from the web browser. I would rather display some custom HTML indicating the situation to the user if the page navigation is having trouble. What are some commonly-used solutions I should try that would work well for this?
Requirement: must work in IE6 thru IE9. FireFox/WebKit engines won’t be used for this application.
…………………………………..

A simple way will be to try to load a known small image and you detect if the loading is done or not.
onload=”window.location=’http://www.rgagnon.com’;”
onerror=”window.location=’http://www.google.com’;”
>If the pdf.gif is loaded, we switch to the site, if not we go somewhere else.
…………………………………..

You could use an AJAX style request on load to assure the server is alive before redirecting the browser to it, but there is no guarantee the server will still be alive when the redirection occurs.

For more info: Redirect browser only if a web site is available

HTML Language Development » Search Results » ajax

Redirect browser only if a web site is available

Share this post:

Related Posts

Leave a Comment