Click to See Complete Forum and Search --> : Redirection


trumpcard
01-05-2003, 12:17 AM
I was wondering how to get a html or javascript code that redirected viewers automatically-can someone please help me.

vickers_bits
01-05-2003, 02:38 AM
users can turn off both scripting and meta refreshes, so there is no sure fire way to do this with either on the client.

javascript:
document.location.href="http://www.wherever.com"

meta refresh:
<meta http-equiv="REFRESH" content="0; url=http://www.wherever.com">

Stefan
01-05-2003, 02:38 AM
The best way to do a redirect is to do it serverside. If you don't have access to that you can add eg

<meta http-equiv="Refresh" content="10;URL=home.html">

Changes location to home.html after 10 seconds.

You can do it with JS too, but this works even if JS is turned off in the browser

However remember to always include a normal textlink to the page so people can click it in case the redirect dosn't work.

trumpcard
01-05-2003, 03:41 AM
Thanks for the help.

moob
01-05-2003, 07:39 AM
You can also use

location.replace("http://whatever.com");

The difference between this and location.href is that after using this one you cannot go back in the history.

Zach Elfers
01-05-2003, 03:00 PM
Actually, you can go back. But you have to go back 2 pages. Otherwise, you are redirected again.

jeffmott
01-05-2003, 03:18 PM
Zach Elfers
Actually, you can go back

Did you even bother to try it first? It doesn't allow you to go back because it loads the specified URI over the current history entry.