Javascript Tutorial Example
Example
Javascript Array
JavaScript Boolean
JavaScript Date
JavaScript Math
JavaScript Number
JavaScript String
Javascript Tutorial
Javascript Introduction
Javascript Syntax
Javascript Enable
Javascript Location
Javascript External
Javascript Operators
Javascript Variables
Javascript Functions
Javascript Events
Javascript Statements
Javascript If
Javascript Else If
Javascript While
Javascript For Loop
Javascript Comments
Javascript Array
Javascript Alert
Javascript Confirm
Javascript Prompt
Javascript Print
Javascript Redirect
Javascript Pop Up
Javascript Date
Javascript Form
Javascript Void 0
JavaScript Comparison
JavaScript Switch
JavaScript Try Catch
JavaScript Special Text
JavaScript Throw
JavaScript Math
JavaScript RegExp
Javascript String
Javascript Strings
Javascript Length
Javascript Split
Javascript Search
Javascript Replace
Javascript IndexOf
Javascript Compare
Javascript Advanced
Javascript getElementById
Javascript innerHTML
JavaScript Browser
JavaScript Cookies
JavaScript Animation
JavaScript Image Maps
JavaScript Timing
JavaScript Create Objects
JavaScript Summary
You're moving to a new domain name. You have a time-delay placeholder on your download site. You have a list of external web servers that are helping to mirror your site. What will help you deal with and/or take advantage of these situations? JavaScript redirects will.
When your webpage is moved, you'd probably want to notify your visitors of the change. One good way is to place a "redirect page" at the old location which, after a timed delay, will forward visitors to the new location of your webpage. You can do just this with a JavaScript redirection.
Control over what page is loaded into the browser rests in the JavaScript property window.location. By setting window.location equal to a new URL, you will in turn change the current webpage to the one that is specified. If you wanted to redirect all your visitors to www.google.com when they arrived at your site, you would just need the script below:
<script type="text/javascript">
<!--
window.location = "http://www.google.com/"
//-->
</script>
Implementing a timed delay in JavaScript is useful in the following situations:
The code for this timed delay is slightly involved and is beyond the scope of this tutorial. However, we have tested it and it seems to function properly.
<html>
<head>
<script type="text/javascript">
<!--
function delayer(){
window.location = "../javascriptfilenameredirect.php"
}
//-->
</script>
</head>
<body onLoad="setTimeout('delayer()', 6000)">
<h2>Prepare to be redirected!</h2>
<p>This page is a time delay redirect, please update your bookmarks to our new
location!</p>
</body>
</html>
The most important part of getting the delay to work is being sure to use the JavaScript function setTimeout. We want the delayer() function to be used after 6 seconds or 6000 milliseconds (6 seconds), so we pass the setTimeout() two arguments.
* 'delayer()' - The function we want setTimeout() to execute after the specified delay.
* 6000 - the number of millisecods we want setTimeout() to wait before executing our function. 1000 miliseconds = 1 second.
Do use JavaScript for redirections when you change your website's URL or move a file to a new location. Don't use redirections when they can easily be replaced with a normal HTML hyperlink.

