2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018

03/03/2003: How to Redirect to New URL Using JavaScript?

How to Redirect to New URL Using JavaScript?

This example shows how to redirect a web browser to another page. The JavaScript performs a countdown of the number of seconds left before the redirection is performed.

<HTML>
<HEAD>
  <TITLE>"Some Page" has moved!</TITLE>
  <META HTTP-EQUIV=Refresh CONTENT=6;URL=http://www.codebits.com/>
  <SCRIPT LANGUAGE="Javascript">
    <!--
    function countdown() {
      if ( document.myform.count.value > 0 ) {
        document.myform.count.value = document.myform.count.value-1;
        setTimeout("countdown()", 1000);
      }
    }
    //-->
  </SCRIPT>
  </HEAD>
  <BODY><H1>"Some Page" has Moved!</H1>
  The new address is:
  <A HREF="http://www.codebits.com/" TARGET=_top>http://www.codebits.com</A>.
  <P><FORM NAME=myform>
  You will be redirected to the above page in
  <INPUT NAME="count" SIZE="1" value="6"> secs.....)</FORM>
  <SCRIPT LANGUAGE="Javascript">
    <!--
    countdown();
    //-->
  </SCRIPT>
  </BODY>
</HTML>


subscribe via RSS