[thelist] Avoiding a redirect loop

Peter-Paul Koch gassinaumasis at hotmail.com
Fri Mar 16 06:25:14 CST 2001


>that it doesn't force a redirect avoids the potential complications of 
>aredirect loop when the browser Back button is pressed.

Avoiding it is very simple:

<TIP TYPE="Avoiding a redirect loop" AUTHOR="ppk">
When you redirect the user with JavaScript to another page, do NOT do

location.href = 'newpage.html';

because when the user presses Back on this page, he'll go back to the 
redirect page and then be redirected once again, no doubt causing tons of 
confusion.

Instead use

location.replace('newpage.html');

This replaces the redirect page with the new page in the browser history, so 
that when the user presses Back he goes to the page before the redirect 
page.
</TIP>

ppk

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.





More information about the thelist mailing list