...

View Full Version : Automatic page redirection



charter
04-22-2004, 12: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

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

No script necessary.

jbot
04-22-2004, 02: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) ;

</script>


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

Choopernickel
04-22-2004, 03: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.

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum