View Full Version : Automatic page redirection

04-22-2004, 01:57 PM
I have been looking for a script so that you can be redirected to another page without clicking on a link.

An example of what I wish to attain happens on this site.

On this site when you have logged in you get a page which is a redirection page and after about 10 seconds it automatically redirects you to the main forum page.
Also a secondary button so that if it doesn't work.

Has anyone any idea where I can get hold of such a script.

I need this script as the URL of a page is changing and so that anyone who links from an external website they will be redirected to the page with the new URL. This is to give external websites the chance to update their links.

All help much appreciated

04-22-2004, 02:59 PM
<html><head><title>Page Moved.</title>
<meta http-equiv="Refresh" content="5, your URL here" />
<p>This page has moved, and should redirect you.</p>
<a href="your URL here">Please update your bookmarks.</a>

No script necessary.

04-22-2004, 03:20 PM
the problem with meta refresh is that it stays in the browser's history, so clicking back wouldn't get you anywhere - you'd just get redirected back to whence you came.

it's better (and far less annoying to the user) to use JS for this. in the head of the document, put:

<script language="Javascript">

var sUrl = "yourpath_or_url" ;
location.replace(sUrl) ;


you can still use a meta-refresh for non-JS browsers, such as web-bots, so they can still navigate your site. to do this, again in the head of the document type this:

<noscript><meta http-equiv="Refresh" content="5, your URL here" /></noscript>

ok?! :D

04-22-2004, 04:56 PM
Giving a five-second redirect when a site's URL changes is not typically considered an inconvenience, nor does it break the back button (not that yours breaks it either). It's a classic, de facto standard way to alert a surfer that a site has moved, and that bookmarks to the site should be updated.

04-23-2004, 10:09 AM
Many thanks to Choopernickel & J-Bot.