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>