为什么这个js-php生成的位置引用在IE8中不起作用?

时间:2012-04-17 18:46:10

标签: php javascript internet-explorer internet-explorer-8

为什么这个js-php生成的位置引用在IE8中不起作用?

<script>
<?php
    session_start();
        $_SESSION['admintermorol']=false;
        echo "window.location='".$_SERVER['HTTP_REFERER']."';";
?>
</script>

1 个答案:

答案 0 :(得分:2)

我不确定,但你可以用纯PHP做到这一点,替换

echo "window.location='".$_SERVER['HTTP_REFERER']."';"; 

exit(header("Location: {$_SERVER['HTTP_REFERER']}\r\n"));

抱歉,这有点不对

将代码移动到页面顶部(不在脚本标记内)

<?php
session_start();
if ( !isset($_SESSION['admintermorol']))
{
    exit(header("Location: {$_SERVER['HTTP_REFERER']}\r\n"));
}
?>

或者(现在我知道)你可以这样做: - )

<?php
session_start();
$_SESSION['admintermorol'] = FALSE;
exit(header("Location: {$_SERVER['HTTP_REFERER']}\r\n"));
?>
相关问题