Javascript Redirect

a post by Alec, filed in Websites, html, internet on January 17th, 2008. Read the full post »

This is a Javascript Redirect with a delay of 3 seconds


<script type="text/javascript">
<!--
setTimeout('window.location="http://www.google.com"', 3000);
//-->
</script>

This is valid XHTML and you need to put this code in between the <head> and </head> tags of your page. The 3000 means the page will redirect in 3000 milliseconds–or 3 seconds, change it to be what you want.

Do you want an instantaneous redirect? Here’s the code (same rules apply as above):

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

The address can be relative or absolute. People may have Javascript turned off, so I find a PHP redirect much better.

Tags: , , , ,
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
  1. The Cipher: Blog » Blog Archive » PHP Redirect January 17, 2008

    [...] redirects are better than Javascript redirects because it is done server side and there is no possibility of the user having JS turned off and not [...]

  2. Alec July 23, 2008

    Oops, that doesn’t work! You need to the line to read “window.location.href” instead.

Post a Comment »








Safari hates me

Comment Guidelines

  • Hyperlinks are automatically generated.
  • <em>italic</em>
  • <strong>bold</strong>