Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirect causes endless loop

Status
Not open for further replies.

cactus1000

Programmer
Aug 31, 2001
149
US
I know this is an easy one (I've dealt with this in the past, but can't remember how).

I replaced an old web page with a redirect to my new one using the JavaScript "location.replace" function.

However, when you get to the new page and hit the "back" button on the browser, you get stuck in an endless loop. (i.e., you go back to the redirect, which takes you to the page you are trying to leave, etc.)

What is the code to have the "back" function skip the redirect page?
 
<a href=&quot;#&quot; onClick=&quot;history.go(-2)&quot;>Back</a>

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
You could also put some code on the page that redirects and make sure not to redirect if the referrer is the page you are going to...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rich Cook
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top