Javascript Redirect Overview

When you want to move a web page to a new location, perhaps a new domain, there are a number of ways to take your web site visitors to the new location. One of the simplest to implement is the javascript redirect. It has the advantages of being independent of the web server and requiring minimal coding skills to implement.

Javascript window.location Code

In javascript the command to implement a redirect is window.location = New URL. The code to add to your HTML on the web page is as below, for the fastest response the code should be added inside the HEAD tag

<script type="text/javascript">
<!--
window.location = "http://www.example.com/";
//-->
</script>

The code above redirects from the page it is on to www.example.com - to implement the code on your own site change the http://www.example.com/ to your destination URL.

The following link shows an example of an immediate javascript redirect in action:

http://www.javascriptredirect.com/example-immediate.htm

Add More Complexity

For more complex situations - for instance conditional redirects or timed redirects additional code is required in your javascript script block.