php后台跳出框架集

在后台管理系统中,一般使用框架集来分隔显示管理页面,但是若检测到session过期需要跳出框架集时,php后台要怎么操作?

if(no_login()){
    exit("<script>top.location.href='login.php';</script>");
}

这里的top其实就是a标签的target=’_top’的对应。

补充

2015.7.28
无独有偶,今天又遇到了跳转没反应,这回是登陆跳转,怎么会,我也不信,先看代码!

<?php
if (!empty($_POST)) {
    header('location: https://newbmiao.github.io');
    exit;
}
?>


<form method='post' target='hiddenwin'>
    <table>
        <tr>
            <th>用户名</th>
            <td><input type='text' name='account' id='account'/></td>
        </tr>
        <tr>
            <th>密码</th>
            <td><input type='password' name='password'/></td>
        </tr>
        <tr>
            <th></th>
            <td>
                <button type='submit' id='submit'>登录</button>
            </td>
        </tr>
    </table>
</form>
<iframe frameborder='0' name='hiddenwin' id='hiddenwin' scrolling='no'></iframe>

看到没,form里的那个target,请求内容要呈现的目标容器指定,所以header请求的跳转是生效了,但是放到了,那个隐藏的iframe里,所以感觉没有跳转。坑爹的iframe伪装不刷新!

要解决,还是要用top或者parent去作为目标容器。


附target列表:

  • _blank 在新窗口中打开被链接文档。
  • _self 默认。在相同的框架中打开被链接文档。
  • _parent 在父框架集中打开被链接文档。
  • _top 在整个窗口中打开被链接文档。 framename 在指定的框架中打开被链接文档。
如有疑问,请文末留言交流或邮件:newbvirgil@gmail.com 本文链接 : https://newbmiao.github.io/2015/01/11/php-jump-out-of-the-frameset.html