Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

whocares

macrumors 65816
Original poster
Oct 9, 2002
1,494
0
:noitаɔo˩
Here's the deal. I have a website on my ISP server. I am also developing a website on my Mac (PHP, MySQL and unlimited storage all come free...). What I would like to do is redirect the wabsite to my Mac *if* my Mac is turned on, ie get the index page to ping my IP a re-direct if possible. If my Mac is not connected I would like the index page to redirect itself to a page on my ISP server.

Is there a way of doing this. Javascript would the best as it's the only scripting language supported by my ISP. I am a complete beginner with JScript but willing to get my hands "dirty".

Thanks for you help :)
 

ehwizard

macrumors newbie
Jan 28, 2003
16
0
New York, NY
Easy Method

Here's a pretty easy method.

On the mac, have a file called something like redirectHere.js

it should have something like:

--- START CODE----
function comeHere(){
location.replace(<your server location>);
}
--- END CODE

then on the isp you have your normal html page and modify like this:

---- START CODE---
<html>
<head>
<script src="<mac server>/redirecthere.js">
</script>
</head>
<body onLoad="comeHere()">
</body>
</html>
---- END CODE---

When the mac is up it will get the javascript from the mac and redirect there.
When it is not running it will not be able to get the javascript so will not redirect.

You should also put no caching directives so that the redirection page is not cached.

That should do it,
-Eliot
 

whocares

macrumors 65816
Original poster
Oct 9, 2002
1,494
0
:noitаɔo˩
Originally posted by Rower_CPU
Just to let you guys know, there's a dedicated forum for web design discussion. :)

Oooooops. My Bad :)

Thanks ehwizard, I'll see if that works.

[edit]

ok, I've tried and basically the JScript isn't loading into the page. It stays as a plain URL between the quotes.
What am I doing wrong?

[/edit]
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.