Quackit Logo
HTML
CSS
Scripting
Database
Hosting
Design
XML

Print Version

JavaScript Redirect

A URL redirect or URL redirection usually refers to when a web page, as soon as it is loaded, redirects to another web page. This technique can be useful if the content on your page has moved to another page.

In JavaScript, you script a redirect using the same code you use to load a page.

Redirect code

To create a JavaScript redirect, place the following code between the head tags of your HTML page (replacing the URL with the URL that you want to redirect to).

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

In the above example, the page will only redirect if the user has JavaScript enabled on their browser. If you want the redirection to occur regardless, try using an HTML redirect.

Enjoy this website?

  • Share
  • Add this page to your Favorites
  • Link to this page (copy/paste into your own website or blog):
  • Link to Quackit using one of these banner ads.
  • Help support Quackit by making a donation

Oh, and thank you for supporting Quackit!

© Copyright 2000 - 2010 Quackit.com