Trying to understand redirection script behaviour.

Discussion in 'Javascript' started by pdc, Feb 14, 2006.

  1. pdc

    pdc Guest

    I 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.
    -->
    <head>
    <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 =
    "http://webserver1/ThisGIFimageControlsWhichWebServerisChosen.gif";
    -->
    </SCRIPT>
    <HTML>

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

    Using Firefox (1.5.0.1)
    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?
     
    pdc, Feb 14, 2006
    #1
    1. Advertising

  2. pdc

    pdc Guest

    just to add, my firefox browser has enabled javascript
    thanks!
    "pdc" <> wrote in message
    news:lClIf.1896$...
    >I 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.
    > -->
    > <head>
    > <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 =
    > "http://webserver1/ThisGIFimageControlsWhichWebServerisChosen.gif";
    > -->
    > </SCRIPT>
    > <HTML>
    >
    > IE. the redirection proceeds as required. Trouble is, I don't want to use
    > IE.
    >
    > Using Firefox (1.5.0.1)
    > 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?
    >
    >
    >
     
    pdc, Feb 14, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phoe6
    Replies:
    4
    Views:
    464
    Dennis Lee Bieber
    Nov 30, 2006
  2. Replies:
    10
    Views:
    577
    Victor Bazarov
    Jul 12, 2006
  3. Nikko
    Replies:
    1
    Views:
    493
    Harry
    Apr 30, 2007
  4. Dan Davison
    Replies:
    3
    Views:
    249
    Dan Davison
    Mar 14, 2009
  5. Kushal Kumaran
    Replies:
    0
    Views:
    599
    Kushal Kumaran
    Apr 1, 2011
Loading...

Share This Page