JavaScript Page Redirect

A redirect is when a web page is visited at a certain URL, it changes to a different URL. For example, a person visits “” in their browser and they are redirected to “” instead.

This is very useful if we want to shut old website and redirect all the traffic to new website. What we need is for those old links to redirect to the same content on our new site.

JavaScript Redirects

Redirecting to another URL with JavaScript is very easy, we simply have to change the location property on the window object and put this code in head section:

window.location = "";

There are some others ways also to redirect

window.location = "";

window.location.href = "";




      <script type = "text/javascript">
                function Redirect()
               window.location = "";
      <p>Click the following button, you will be redirected to new website.</p>
         <input type = "button" value = "Redirect Me" onclick = "Redirect();" />