Results 1 to 8 of 8

Thread: If Host exist.

  1. #1
    Join Date
    May 2005
    Location
    Hawaii
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default If Host exist.

    I am trying to create a javascript that will test to see if a website is online and if it is then refresh the page to that website and if the website is offline then refresh to a different website. I am working on a web server that does not support any server side scripting language, so I can't use php or asp . Any help is appreciated.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    I'm almost 100% sure what you're asking isn't possible with a client side language such as JavaScript. You'll need a server side script such as PHP to do this.

  3. #3
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Yes, as ddadmin, you will need a server side language. I faced this problem when setting up a rather tempremental server, and a solution was easily constructed using PHP.

    cr3
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Actually, it's (just) possible, though not very reliable. Check out the XMLHttpRequest object.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    May 2005
    Location
    Hawaii
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by cr3ative
    Yes, as ddadmin, you will need a server side language. I faced this problem when setting up a rather tempremental server, and a solution was easily constructed using PHP.

    cr3
    How do you do this with php? I just hosted my web site with a new web hosting company that supports php and I would like to do this.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    PHP Code:
    <?php if($fp fsockopen("www.thehost.com"80$errno$errstr10)) {
    fclose($fp);
    header("Location: http://www.thehost.com/");
    } else 
    header("Location: http://www.theotherone.com/"); ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    May 2005
    Location
    Hawaii
    Posts
    52
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks.

  8. #8
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Quote Originally Posted by Twey
    Actually, it's (just) possible, though not very reliable. Check out the XMLHttpRequest object.
    Ah yes, right after I posted my initial response saying it wasn't possible, I thought of Ajax. But like you said this really is something best done using a purely server side approach.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •