使用javascript进行PHP页面重定向

ans*_*shu 5 php redirect

一个小问题!我在PHP文件中有一个登录表单.我已经对表单使用了javascript验证.在登录成功方案中,我将用户重定向到他们的主页.

我用过header("Location:index.php").

我知道标题必须在任何输出必须发送到浏览器之前.我的问题是有没有任何走动来做这个重定向?

Tom*_*Tom 19

你可以用

<script>
    window.location = 'http://www.example.com/newlocation';
</script>
Run Code Online (Sandbox Code Playgroud)

发送标头后重定向.