SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    redirection script

    can anyone give me a simple redirection script? something suitable for "You'll be taken to this page in 5 seconds... if not you can click on this link"

    i did a search at hotscipts but turned out lots of complicated scripts...

  2. #2
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here ya go:
    Code:
    <script type="text/javascript">
    <!--
    delay = 5;
    if (location.search.length > 1) {
    	url = unescape(location.search.substring(1,location.search.length));
    	document.writeln('You will be transfered to ' + url + ' in <b>' + delay + '</b> seconds, or you can just');
    	document.writeln('<a href="' + url + '">click here</a>.');
    	setTimeout('location.href = "' + url + '"',delay * 1000);
    	}
    else document.writeln('Error: no redirection url defined.');
    //-->
    </script>
    ck :: bringing chris to the masses.

  3. #3
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How about good 'ol:
    Code:
    <meta http-equiv=refresh content="5; url=http://www.whereiwantyoutogo.com">
    You will be taken to the new page in 5 seconds.
    If not, you can click <a href="http://www.whereiwantyoutogo.com">here</a>.
    Works even when the user has JavaScript disabled.

    - Marshall

  4. #4
    You talkin to me? Anarchos's Avatar
    Join Date
    Oct 2000
    Location
    Austin, TX
    Posts
    1,438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The point of mine was that you don't need to create a separate page for each individual url you want to forward, you just pass it onto the query string, e.g.

    redirect.html?http://sitepoint.com
    redirect.html?http://www.slashdot.org

    I believe that was the implication of "script".
    ck :: bringing chris to the masses.

  5. #5
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No arguments with Anarchos' interpretation of 'script' :-) At the risk of being "out-of-forum" here's a better method for doing redirects that uses PHP:

    Code:
    Header('HTTP/1.1 302 Redirected');
    Header('Location: '.urldecode($redirect));
    This would be called with a query such as:
    Code:
    redirect.php?redirect=http://www.somewhere.com
    -Marshall

  6. #6
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks guys for you help

    in the end all i needed was this:
    Code:
    <meta http-equiv=refresh content="5; url=http://www.whereiwantyoutogo.com">
    You will be taken to the new page in 5 seconds.
    If not, you can click <a href="http://www.whereiwantyoutogo.com">here</a>.
    yup and i'm sorry i said script... because turned out i only needed a meta tag


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
  •