JavaScript redirect page

Home - Tutorials - Basics

This article helps you to learn how to use Javascript redirect possibilities and show you some code easy code examples.

Tutorial info:

Name:JavaScript redirect page
Total steps:1
Product:See complete product

Bookmark JavaScript redirect page

AddThis Social Bookmark Button

Step 1 - JavaScript redirect usage

JavaScript redirect page

During reorganization of your website it can happen that you want to redirect your visitor to an other page. You can do this many ways, like PHP, HTML, JavaScript. On this page we focus on the JavaScript solution.
You should know however, that if JavaScript is disabled in your visitors browser, then this way will not work and you need to use an other redirecting method.

The simplest way to redirect the user with JavaScript is setting the window.location property to the URL you want to redirect to as follows:
  1. <script type="text/javascript">
  2.     window.location = ""
  3. </script>
As you can see the code is very simple. 

Sometimes you don’t want to redirect the user immediately, but a bit later.  For example you want to inform the visitor why and where he or she will be redirected. To solve this problem we need to setup some delay before redirecting using the setTimout() function as you can see in the following code example: 
  1. This page will be redirected in 5 seconds...
  2. <script type="text/javascript">
  3.     setTimeout('window.location = ""', 5000);
  4. </script>
I hope this short description helps you to use JavaScript redirect to any page solution properly. 

Tags: javascript redirect page, javascript redirect, redirect page, javascript, redirect, page

JavaScript redirect page - Table of contents
Step 1 - JavaScript redirect usage

GAD Tower

Family tutorials
PHP Array
PHP Redirect
PHP Session
AJAX File Upload
AJAX Rating System
MySQL Create User
Mysqldump Example
MySQL Concat

Total time: 2.9198