Friday, December 14, 2012

Javascript: Page redirection

Javascript: Page redirection

Page redirection is very usefull technique for website development. If a user opens an x page then by using redirection method you can tell to open y page. But still users think they are viewing x page.

This is very helpfull in the case when you move your domain name. And when some one enters the same url you can redirect to some other site without actually disturbing the visitors or any interuptions.



Syntax:

window.location="url";

Example:

<head>
<script type="text/javascript">
<!--
function Redirect()
{
    window.location="http://www.google.com";
}

document.write("You will be redirected to main page in 10 sec.");
setTimeout('Redirect()', 10000);
//-->
</script>
</head>

No comments:

Post a Comment