Page 1 of 1

How to self redirect a page to another page on load

Posted: Thu Nov 11, 2010 5:35 pm
by Saman
There are situation that we need to redirect to another page when we open a page. Here is the code for that.

Code: Select all

<html>
<head>
<script language="javascript" type="text/javascript">
    function redirect () {
        window.location.href = "http://yoururl.com/yourpage.html";
    }    
</script>
</head>
<body onload="redirect()">
</body>
</html>

Re: How to self redirect a page to another page on load

Posted: Tue Mar 01, 2011 2:33 pm
by Pansophic
nice script over there, this can also be done by using php

Code: Select all

<?php
header("location : http://google.com");
?>