Challenge of Day

Wednesday, February 11, 2009

How to automatically redirect a browser to another web page

You might have been looking for this basic question. Suppose that you have page1 but the whole contents have been moved to new address and at the same time you do not want remove page1 completely. How do you redirect visitors to new address automatically?
Two easy solutions:
1 - Use "refresh" meta command:
The syntax for the "refresh" meta command is
{meta http-equiv="refresh" content="N; URL=other-web-address"}
(do not forget to replace { with < and } with >)
where N is the approximate number of seconds that you want the current web page to be displayed before the browser automatically goes to the other web address. If N=0, then the browser should go immediately to the other web address.
Here is an example:
{meta http-equiv="refresh" content="4; URL="}

2 - Using JavaScript:
By using JavaScript, you can easily redirect user as well:
script language="javascript" type="text/javascript">
window.setTimeout('window.location=""; ',4000);
// --}

Be a winner in your daily challenges

Ali Khademi


Post a Comment

Subscribe to Post Comments [Atom]

<< Home