• 关于js的地址跳转


    一、基本的地址跳转

    解说:

    window.open 弹出新窗口的命令;     page.html' 弹出窗口的文件名;    'newwindow' 弹出窗口的名字(不是文件名),非必须,可用空'代替; height=100 窗口高度;  width=500 窗口宽度;  top=0 窗口距离屏幕上方的象素值;  left=0 窗口距离屏幕左侧的象素值。

    window.location.href = "页面地址"; //当前页跳转  相当于 <a href="baidu.com" target="_self">go baidu</a>  
    window.open('页面地址'); //打开新页面   相当于<a href="baidu.com" target="_blank">go baidu</a>
    window.open('page.html', 'newwindow', 'height=100, width=400, top=0,left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')

     

    二、返回上一页,当页刷新

    window.history.back(-1); //返回上一页
    window.history.back(); //返回上一页
    document.referrer;  //返回上一页,也用于获取上一页的链接,假如没有上一页则返回"",多用于移动端
    
    location.reload(); //当页刷新
    window.location.go(-1); //返回上一页并刷新
    self.location=document.referrer; //返回上一页并刷新
    

      

    三、其他的页面跳转

    解说:

     self 指代当前窗口对象,属于window 最上层的对象。

    location.href 指的是某window对象的url的地址

     self.location.href 指当前窗口的url地址,去掉self默认为当前窗口的url地址,一般用于防止外部的引用

    top.location.href:为引用test.html页面url的父窗口对象的url

    top指代的是主体窗口

    self.location.href = "baidu.com" 
    top.location.href = '页面地址';
    
    //假如要页面a跳出iframe框架
    if(top.location.href != self.location.href) {
    	location.href = "页面a";
    }
    

      

  • 相关阅读:
    例行性工作排程 (crontab)
    数组
    继续我们的学习。这次鸟哥讲的是LVM。。。磁盘管理 最后链接文章没有看
    htop资源管理器
    转:SSL协议详解
    转:SSL 握手协议详解
    转:Connection reset原因分析和解决方案
    使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)
    转:logback的使用和logback.xml详解
    转:Java logger组件:slf4j, jcl, jul, log4j, logback, log4j2
  • 原文地址:https://www.cnblogs.com/qqing/p/8436717.html
Copyright © 2020-2023  润新知