How to redirect to a new page in JavaScript

In this article we will discuss about how to direct from one page to another in JavaScript.
  • 2083

If we want to navigate the user from the old site to new one we can use the concept of Page Redirection in JavaScript. Now the question raise why we use the page redirection concept in JavaScript the reason is that if we did not like our old domain and we want to move to a new domain then but at the same time we want our visitors to direct to this new domain at the same time we can maintain our old website by putting a single page with a page-redirection so that our old visitors can direct to our new website.

JavaScript Code:

<head>

    <script type="text/javascript">

<!--

        function Redirect() {

            window.location = "http://www.google.com";

        }

 

        document.write("Wait for the 10 sec. to be redirected to the new location or google website");

        setTimeout('Redirect()', 10000);

//-->

    </script>

</head>

 
Output:

Image31.jpg

When we will wait for 10 seconds after 10 seconds a google website will be open.

Ask Your Question 

Got a programming related question? You may want to post your question here
 
© 2019 DotNetHeaven. All rights reserved.