[thelist] Using Location.href Vs location.replace

Peter-Paul Koch gassinaumasis at hotmail.com
Thu Mar 20 09:40:50 CST 2003

>hi guys
>Where is the benefit in using     location.replace(url)
>as opposed to     location.href = url.

location.replace() is useful when you redirect users to another page. If 
you'd use location.href and the user would click 'Back', he'd go back to the 
redirection page which redirects him forward once again.
Since replace() overwrites the previous entry in the history, this problem 
is eliminated.

>AFAIK, usage of .replace is browser-dependant.

So is location.href, but both are very well supported.

ppk, freelance web developer
Interaction, copywriting, JavaScript, integration
Column "Keep it Simple": http://www.digital-web.com/columns/keepitsimple/
W3C DOM Compatibility Table, expanded & updated

MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 

More information about the thelist mailing list