Hello everyone. Does anyone know if it is possible to redirect a browser with Javascript? If it is, could someone please give me a clue as to how it is done? I have searched the w3schools tutorial where I started learning Javascript but can't find anything on this. Any help would be appriciated. Thanks.


There is also the window.replace() method, which takes a string inside the parantheses. The difference between the .replace() method and the .location property, is that .replace() doesn't store the new page in the browser history.

This code is used specifically to redirect one Web page to another (i.e. if your Web site has moved, put this code at the old location)

    <title>Redirect JavaScript-browsers</title>

    <script language="JavaScript">
      <!-- Beginning of JavaScript --------
        this.location = "http://www.newsite.com";
      // -- End of JavaScript code -------------- -->


    This site is now located at <a href="http://www.newsite.com">http://www.newsite.com</a>.

I hope that helps you out.

commented: Very helpfull. +1