Fog Creek Software
Discussion Board

Knowledge Base
Terry's Tips
Darren's Tips

Redirect javascript

Frustration setting in. I picked up the javascript below from somewhere. It is supposed to be a proper redirect. I find, however, that won't allow the back button to work. Any guru-type input greatly appreciated. Bottom line: what's the best way to redirect from CD to an outside file?

<!-- Begin
// End -->
You should be redirected automatically. If not, click <a href="newfolder/page1.htm">here</a>.

Wednesday, February 19, 2003

I think this will be a problem with whatever re-direct you do. See, the previous page you were on is the redirect page, so when you go back, it automatically fowards you to the next page.

Maybe a javascript that invokes history -2 (or something like that, I don't know the syntax) might work for you.
Thursday, February 20, 2003

You could also open the new page in a new window with target="_blank" in the href tag. A little clumsy perhaps, but this way people would know, that they were redirected.

Jorgen Brenting
Thursday, February 20, 2003

Its better to do this from the server side.

joel Goldstick
Thursday, February 20, 2003

Here's one way to do a redirect (though the best way is to configure the web server to do it).

<META http-equiv="refresh" content="10;URL=">
<TITLE>The page you were attempting to access no longer exists!</TITLE>

The page you were attempting to access no longer exists. <br>
<a href="/">Click here to go to the <i>newdomain.dom</i> if you are not automagically taken there within 10 seconds.

David Burch
Thursday, February 20, 2003

I was thinking of posting the Meta Refresh, but thought better of it.

But now that David posted it, I realized that this is a good alternative - the 10 seconds it takes for the page to change over will give whoever hits the back button ample time to hit it again.
Thursday, February 20, 2003

A 10 second wait will also look good to the search engines. They do not like zero seconds redirect and might take you for a bad guy if you are too fast on the trigger (no similarities intended).

Jorgen Brenting
Friday, February 21, 2003

Thanks for the script!  I was looking for something this simple for a while. I was useing .js files before to do the same thing....

Friday, January 30, 2004

*  Recent Topics

*  Fog Creek Home