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
Category:Basics
Date:2010-08-05
Level:Beginner
Product:See complete product
Viewed:11360

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:
 
Code:
  1. <script type="text/javascript">
  2.     window.location = "http://www.javascriptf1.com"
  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: 
 
Code:
  1. This page will be redirected in 5 seconds...
  2. <script type="text/javascript">
  3.     setTimeout('window.location = "http://www.javascriptf1.com"', 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


F1 Site Family
AJAX F1
CSS F1
Database F1
HTML F1
Java F1
JavaScript F1
PHP F1

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

Total time: 0.1951