99
rated 0 times
[
102]
[
3]
/ answers: 1 / hits: 79249
/ 12 Years ago, wed, april 11, 2012, 12:00:00
I have a function which echoes javascript to navigate to a different page. While navigation occurs, the
echo 'window.location.href='.$url.';';
does not work and simply prints it on the screen.
window.location.href=./index.php;
I use my function this way: redirect(./index.php);
My php function is as follows
function redirect($url)
{
if (!headers_sent())
{
header('Location: '.$url);
exit;
}
else
{
echo '<script type=text/javascript>';
echo 'window.location.href='.$url.';';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv=refresh content=0;url='.$url.' />';
echo '</noscript>'; exit;
}
}
More From » php