Quackit Logo
HTML
CSS
Scripting
Database
Hosting
Design
XML
Website builder

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 page?

  1. Add this page to your Favorites
  2. Link to this page (copy/paste into your own website or blog):
  3. Link to Quackit using one of these banner ads.

Thanks for supporting Quackit!