View Full Version : If Host exist.
dead-poetic
10-15-2005, 12:50 AM
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.
ddadmin
10-15-2005, 11:06 PM
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.
cr3ative
10-16-2005, 07:37 AM
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
Actually, it's (just) possible, though not very reliable. Check out the XMLHttpRequest (http://jibbering.com/2002/4/httprequest.html) object.
dead-poetic
10-16-2005, 06:15 PM
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.
<?php if($fp = fsockopen("www.thehost.com", 80, $errno, $errstr, 10)) {
fclose($fp);
header("Location: http://www.thehost.com/");
} else header("Location: http://www.theotherone.com/"); ?>
dead-poetic
10-16-2005, 07:51 PM
Thanks.
ddadmin
10-17-2005, 06:33 PM
Actually, it's (just) possible, though not very reliable. Check out the XMLHttpRequest (http://jibbering.com/2002/4/httprequest.html) 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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.