JavaScript Page Redirect - Java Script

What is Page Redirection ?

You might have come across a situation where you have clicked a URL to reach a page M but you were landed on another page N.

This is called Page redirecting or Page forwarding.

One will have different reasons to redirect a user from the actual page.

Below are few reasons to do so −

  • In Case if you did not like your domain name and you are moving to a new domain then in such situation you can use page redirectionor Page forwardingin order to direct all your users visiting your old site to visit This can be done by simply putting a single page redirection in your old site.
  • You might have built-up different pages depending upon browser versions or their names or may be depending uponvarious countries, then you can substitute server side page forwarding or page redirection with client side page forwarding or page redirection todirect your users on the suitable page.
  • The Search Engines may have indexed your web pages earlier. But while moving from one domain to another domain, you would not like to lose your visitors coming through search engines. In such situation you can use client side page forwarding or page redirection. But make sure this should not be done to deceive the search engine, it leadsto banning of your site.

How Page Re-direction Works ?

Here are few examples which explains how page redirection works-

Example 1

It is quite easy to do a page forwarding/redirection using client side JavaScript .You have add a new line in your head section in your code in order to redirect your visitors to your new page


Output:

Example 2:

You can displayansuitable message to your site visitors before landing them to a new web page. This includes a bit time lag to load a new web page. The following example illustrates how to perform the same. Using settimeout() function in JavaScript one can perform another function after mentioned time interval.

Output:

JavaScript Page Redirect Output

You will be redirected to wisdomjobs.com main page in 10 seconds!

Example 3:

The below example illustrates how to land your site visitors onto a different page depending upon their browsers.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Java Script Topics