Quackit Logo

Got a MySpace Page?

Get "www.yourname.com" for your MySpace page. Learn how >>.

JavaScript Redirect

Print Version

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?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
                     
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!