How to self redirect a page to another page on load

Web programming topics
Post Reply
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

How to self redirect a page to another page on load

Post by Saman » Thu Nov 11, 2010 5:35 pm

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>
Pansophic
Sergeant
Sergeant
Posts: 25
Joined: Sun Feb 13, 2011 4:05 pm

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

Post by Pansophic » Tue Mar 01, 2011 2:33 pm

nice script over there, this can also be done by using php

Code: Select all

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

Return to “Web programming”