[thelist] Redirect Javascript

Theodore Serbinski need-4-speed-ski at erols.com
Wed Jul 12 11:45:50 CDT 2000


> I've been spending too much time looking for a snipett of code to redirect
> people away from a mirror site on a free (read slow) host to my regular
> server. All my "redirect" Javascript sources are the scripts that check if
> the user is enabled for js.  I just want to move them to the new
> site, then
> later take the old one down. Can someone help me out on this one?

Well the correct way of doing this or I guess the best way that doesn't
compromise usability would be to actually "replace" the location instead of
merely redirecting the user. To do that:

window.location.replace("newPage.htm")

However this only works in NN3+ and IE4+. Therefore you can add a few checks
to get the most efficient redirection possible while still trying to keep
the user out of an endless loop when the hit the back button and are forced
forward to the redirect page. Check out this great and short article on a
better method and some good info all around on it.

http://www.insidedhtml.com/tips/functions/ts14/page1.asp'

-ted





More information about the thelist mailing list