Log in

View Full Version : Resolved Php/Javascript redirect



keyboard
06-08-2012, 11:16 PM
Is there any reason not to do this (if I also provide a manual button incase they have got javascript disabled)

<?php
echo '<script type="text/javascript"> window.location = "../..' . $lastPage . '"; </script>';
?>
instead of

<?php
header('location:../..' . $lastpage);
?>


Because I need to redirect based on a condition after some content has been loaded...
Thanks, Keyboard1333

djr33
06-08-2012, 11:34 PM
No reason as long as you don't mind letting the page load first. It will be a lot like a lot of forums and so forth with "please wait while we redirect you..."

Alternatively, you can use a meta refresh tag (with a URL to redirect), which will be a little more reliable in case Javascript is disabled. Still provide the link just in case, but that will work 99%+ of the time.

keyboard
06-09-2012, 01:35 AM
Thanks djr33!