Web page re-directing

Discussion in 'Web Design and Development (archive)' started by whocares, Oct 28, 2003.

  1. macrumors 65816


    Oct 9, 2002
    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 :)
  2. macrumors newbie

    Jan 28, 2003
    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---
    <script src="<mac server>/redirecthere.js">
    <body onLoad="comeHere()">
    ---- 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,
  3. Moderator emeritus


    Oct 5, 2001
    San Diego, CA
    Just to let you guys know, there's a dedicated forum for web design discussion. :)
  4. thread starter macrumors 65816


    Oct 9, 2002
    Oooooops. My Bad :)

    Thanks ehwizard, I'll see if that works.


    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?


Share This Page