Introduction
- Introduction to JavaScript: Day 1
- Programming Basics in JavaScript: Day 2
- Comments and Objects in JavaScript: Day 3
- Scope and Events in JavaScript: Day 4
- Array in JavaScript: Day 5
Page Re-direction in JavaScript

- One reason we just discussed in the previous example. The browser gets your location and asks for the change of the page and that button click event page is redirected.
- If you have created a new domain and you want to redirect all your visitors from the old to the new domain.
The following are the various page redirection methods, to redirect from one page to another in JavaScript.
These methods are used for redirecting to another page; just add this code to the head section:
- Using window.location.
Example
- <script type="text/javascript">
- <!--
- window.location="http://www.c-sharpcorner.com";
- //-->
- </script>
- Using window.location.href.
Example
- <script type="text/javascript">
- <!--
- window.location.href="http://www.c-sharpcorner.com";
- //-->
- </script>
- Using window.location.assign.
Example
- <script type="text/javascript">
- <!--
- window.location.assign="http://www.c-sharpcorner.com";
- //-->
- </script>
- Using window.location.replace.
Example
- <script type="text/javascript">
- <!--
- window.location.replace="http://www.c-sharpcorner.com";
- //-->
- </script>
- Using window.open.
Example
- <html>
- <head>
- <script type="text/javascript">
- <!--
- function WinOpen() {
- window.open( "http://www.c-sharpcorner.com/", "OpenWindow", "status = 1, height = 450, width = 450, resizable = 0" )
- }
- //-->
- </script>
- </head>
- <body>
- <input type="button" onClick="WinOpen()" value="WinOpen">
- </body>
- </html>
In the preceding code you see the various properties are used, like height, width, status, resizable, fullscreen, left, right, and so on. The status, resizable and fullscreen is the ON/OFF properties that you can set to 0 for OFF and 1 for ON.



Prasanna Kumar MuduliPosted Jan 23, 2015, 4:52 AM
Nice article,Can you tell me the difference in between example 1 to 4