472,955 Members | 2,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,955 software developers and data experts.

repost: Redirection script

have two web servers that I use, one is the primary and the other is a
backup for when the server is down.
I use a third, central server which redirects a browser's initial link to
one of my web servers.
Rather than getting involved with CGI to determine the status of the web
servers, I found and implemented the following javascript.

<!- this is a very simple page that uses javascript to detect
whether or not a gif file can be obtained from a system's
web server.
If the gif file cannot be found, either because the system
is down or the webserver is inactive, then the imageError
function redirects the browser to a backup server.
<title>PDC's start</title>
<SCRIPT LANGUAGE = "JavaScript">
function imageError()
top.location = "http://webserver2/home.html";
function imageLoad()
top.location = "http://webserver1/home.html";
var imgTest = new Image();
imgTest.onerror = imageError;
imgTest.onload = imageLoad;
imgTest.src =

IE. the redirection proceeds as required. Trouble is, I don't want to use

Using Firefox ( -- it's enabled for javascript --
What I notice is that it is only partially successful in doing what I want.
If I rename the gif file, for example, the redirect works well and
webserver2 is chosen.
But if webserver1 or the machine that webserver1 runs on is down, then the
initial request fails, still trying to access webserver1/home.html
Is this WAD, or is there anything I can tweak to ensure that when webserver1
is unavailable then webserver2 is accessed?

Feb 20 '06 #1
4 1995
I didn't have a clue till I read these


Their answer is to check the naturalWidth (found only in moz/firefox I
think) property of an image, if its non zero then image is ok. Assume
failure with all other values

Feb 20 '06 #2

Wasnt sure about this one and found the links below useful. They both
had a simlar problem, their solution would be check for a nonzero value
in either the width or naturalWidth properties of the image within the
onload function.

Hope these help...

Feb 20 '06 #3
Correction: naturalWidth will always be undefined in IE, only firefox
sets it to a non zero value

What you need in your imageLoad function to handle the firefox bug
is.....( from the talideon link )

if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
// img didnt load and user needs be redirected

Feb 20 '06 #4
You are a god!!

Thanks so much for that, it really helps.

"tihu" <ti********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Correction: naturalWidth will always be undefined in IE, only firefox
sets it to a non zero value

What you need in your imageLoad function to handle the firefox bug
is.....( from the talideon link )

if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
// img didnt load and user needs be redirected

Feb 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Jerry | last post by:
Hi All I would very much appreciate your help: I have two scripts alternating in the background triggering themselves mutually. Here is how: 1.) Script A does something and then calls Script...
by: slash | last post by:
Hi, I have a page on my website that is driven dynamically off of a database by a perl/cgi script. The page contents are essentially reports of the following url:...
by: Manu | last post by:
Hi there, I am using a perl script to generate this html page which just redirects users to my ftp server. The problem is I get a "page cannot be displayed" in IE 6.0 (haven't tried other...
by: Wazz Up | last post by:
Hi, I'm trying run an image slide show where the images rotate once each, then after the last image in the array has been displayed for the specified amount of time, a redirection to another...
by: Taki Jeden | last post by:
Hello everybody Does anybody know why w3c validator can not get pages that use 404 htaccess redirection? I set up two web sites so that clients request non-existent urls, but htaccess redirects...
by: Steph | last post by:
Bonjour, Je souhaite lancer une redirection vers un fichier php via SRC= dans une condition if (voir ci-dessous en bas du script) mais la redirection ne fonctionne pas. Par contre la condition...
by: John Drako | last post by:
I have a database with a lot of links. Every so often I run a script to verify if the URLs are still valid. I weed out the ones with the 404 response. However, many responses are of the 303 kind...
by: comp.lang.php | last post by:
require_once("/users/ppowell/web/php_global_vars.php"); if ($_GET) { // INITIALIZE VARS $fileID = @fopen("$userPath/xml/redirect.xml", 'r'); $stuff = @fread($fileID,...
by: Neil Gould | last post by:
Anthony Jones wrote: That it is awaiting user action. Since a While/Wend or some other on-going background activity of a script appears to provide exceptions to the above statement, your usage...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.