How to redirect a Page Using Javascript in php

If you don't like using header() as I like to redirect page mid-page. This is implemented using
Javascript written through PHP function. Has a die() function at the end for people who has
disabled their Javascript in their browser.

<?php
function redirect($new_location){
   echo ("<script type='text/javascript'>
   document.location.replace('$new_location');
   </script> ");
   die();
}
?>

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...