Get Quote
For page printing of Grant Communications LLC Web Design logo

Website Designer and search engine optimization experts: Call us at (603) 715-5445 for a free initial consultation: SEO - Design

News & Webmaster Resources  


 
 
 

What We Do

View the main topics pages for web design, brand identity, web hosting and training.View how we have brought business development and sales solutions to the table for clients since 1992. How can we help your company achieve the integrated communications results
you need ?
 
 
 
 

Tell a colleague about this website...

 

 

 

 

 

 

JavaScript Redirect

You're moving to a new domain name. You have a time-delay in place on your download site. You have a list of external web servers that are helping to mirror your site. What will help you deal and/or take advantage of these situations? Javascript redirects will.

When a web page is moved will most probably would like to place a "redirect" page at the old location that informs the visitor of the change and then after a timed delay, will forward the visitor to the new location. With the javascript redirection, you can do just this.

Javascript Window.Location

The control over what page is loaded into the browser rests in the javascript propety window.location, by setting this equal to a new URL you will in turn change from the current web page 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:

HTML & Javscript Code:

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

Javascript Time Delay

Implementing a timed delay in javascript is useful for the following situations:

  • Showing an "Update your bookmark" page when you have to change URLs or page locations
  • For download sites that wish to have a few second delay before the page loads and when the download starts
  • To refresh a web page every specified amount of seconds

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 & Javscript Code:

<html>
<head>
<script type="text/javascript">
<!--
function delayer(){
document.location = "../javascriptredirect.php"
}
//-->
</script>
</head>
<body onLoad="setTimeout('delayer()', 5000)">
<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>

View Page:

The most important part of getting the delay to work is being sure to use the javascript function setTimeout. We want the delayer() function be used after 5 seconds or 5000 miliseconds, so we pass the setTimeout() two arguments.

  • 'delayer()' - The function we want setTimeout() to execute after the specified delay.
  • 5000 - the number of milisecods we want setTimeout() to wait before executing our function. 1000 miliseconds = 1 second.

Web Page Redirection

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 could easily be replaced with a normal HTML hyperlink.

 

Web Design

 

   

 

 

 
 

Follow Us

Want to learn more about us? Follow GrantCom LLC, our clients and our companies on Facebook, Twitter, Google+, Blogspot and Linkedin.

Look at our social media connections! Grant Communications LLC on Facebook SEO Experts on FeedBurner GrantCom on Twitter GrantCom on Google+ Internet Marketing on Blogspot SEO Experts on LinkedIn
 

What They Say

 
 
 

Contact us for your web design and SEO needs
Contact us for your web design and SEO needs