zoukankan      html  css  js  c++  java
  • 页面跳转的几种方法

    PHP

    <?php
    
    //302重定向 缺少http://会造成重复重定向
    $url = "http://www.cnblogs.com/mengor";   
    header( "Location: $url" ); 
    
    //301重定向
    $url = "http://www.cnblogs.com/mengor";   
    header( "HTTP/1.1 301 Moved Permanently" );   
    header( "Location: $url" ); 

    //多用于参数错误跳转前-页面
    echo "<script>alert('没有文件上传');history.back(-1)</script>";exit;
     
    //上级页面跳转   多用于后台frame框架(防止出现画中画)
     echo "<script>top.location.href='$url';</script>";exit;
     

    top.location.href=”url”          在顶层页面打开url(跳出框架)

    self.location.href=”url”         仅在本页面打开url地址   

    parent.location.href=”url”      在父窗口打开Url地址   

    this.location.href=”url”       用法和self的用法一致

    window.open('url');        打开一个新窗口

    if (top.location == self.location) 判断当前location 是否为顶层来 禁止frame引用

    实际中可能这样使用  if(top !== self){             top.location.href = location.href;         }   禁止frame引用

     
     

    //关闭当前窗口刷新父窗口(多用于接口回调)
    echo '<script>window.opener.location.reload();window.close();</script>';

     echo "<script>var index = parent.layer.getFrameIndex(window.name); //
           parent.layer.close(index);parent.location.reload();// 关闭layer</script>";

    meta

    <meta http-equiv="refresh" content="5;url=http://www.cnblogs.com/mengor"> 
    

    js

    <script> 
        window.location.href="http://www.cnblogs.com/mengor";
    </script> 
    //a链接父级页面跳转
    <a href="{:url('haowai/other/index',['member_find_id' => $vol.member_id])}" target="_parent" ><img src="{$vol.member_avatar}" class="touxiang" /></a>
  • 相关阅读:
    Kubernetes 服务入口管理 Traefik Ingress Controller
    flex的titlewindow如何自适应浏览器的宽度和高度
    JQuery的事件中使用this
    jQuery控制 input 不可编辑
    jquery 操作 input显示或者隐藏
    Word 创建模板
    HTML转PDF
    SQL server 自增主键重新从1开始
    读取 .properties文件到数据库
    根据json生成java实体类文件
  • 原文地址:https://www.cnblogs.com/mengor/p/8242083.html
Copyright © 2011-2022 走看看