zoukankan      html  css  js  c++  java
  • 实现本页面跳转的几种方式

    html头添加代码

    <meta http-equiv="refresh" content="3; url=http://www.baidu.com/" />

    js实现

    一、最外层top跳转页面,适合用于iframe框架集

    top.window.location.href("http://www.baidu.com");

    ============================================================================================

    二、window.location.href和window.location.replace的区别

      1.window.location.href=“url”:改变url地址;

      2.window.location.replace(“url”):将地址替换成新url,该方法通过指定URL替换当前缓存在历史里(客户端)的项目,
      因此当使用replace方法之后,你不能通过“前进”和“后 退”来访问已经被替换的URL,这个特点对于做一些过渡页面非常有用!

    三、强制页面刷新

      1.window.location.reload():强制刷新页面,从服务器重新请求!

    ============================================================================================

    四、window.location.reload();

    页面实现跳转和刷新:

      1 history.go(0)
      2 location.reload()
      3 location=location
      4 location.assign(location)
      5 document.execCommand('Refresh')
      6 window.navigate(location)
      7 location.replace(location)
      8 document.URL=location.href


    这几个都可以刷新:

      window.location.reload();刷新
      window.location.href=window.location.href;刷新
      window.close();关闭窗口,不弹出系统提示,直接关闭 
      window.close()相当于self属性是当前窗口
      window.parent.close()是parent属性是当前窗口或框架的框架组


    页面实现跳转的九种方法实例:

    1 setTimeout('window.navigate("top.html");',2000);
    2 setTimeout('window.document.location.href="top.html";',2000);
    3 setTimeout('window.document.location="top.html";',2000);
    4 setTimeout('window.location.href="top.html";',2000);
    5 setTimeout('window.location="top.html";',2000);
    6 setTimeout('document.location.href="top.html";',2000); 
    7 setTimeout('document.location="top.html";',2000);
    8 setTimeout('location.href="top.html";',2000);
    9 setTimeout('location.replace("top.html")',2000);

      //window对象

      //document对象
      //location对象
      //href属性


      //1.window.document.location.href
      //2.window.document.location
      //3.window.location.href
      //4.window.location

      //5.document.location.href
      //6.document.location
      //7.location.href
      //8.window.navigate
      //9.location.replace

    只要使用location方法,和任意的window对象,location对象,href属性连用,都可以页面的跳转

    解释:
      location是个对象,比如本页的document.location和window.location的属性有
      location.hostname = community.csdn.net
      location.href = http://community.csdn.net/Expert/topic/4033/4033372.xml?temp=2.695864E-02
      location.host = community.csdn.net
      location.hash =
      location.port =
      location.pathname = /Expert/topic/4033/4033372.xml
      location.search = ?temp=2.695864E-02
      location.protocol = http:
    可见href是location的属性,类别是string。

  • 相关阅读:
    转载:从51CTO转来的两篇关于SQL的文章
    转载:几万年前,有一只猴子大闹地府后删库跑路...
    【java/oralce/sql】往一张仅有id,名称,创建时间三个字段的表中插入百万数据需要多久?1分26秒
    处处留心皆学问
    [oracle/java/sql]用于上十万批量数据插入Oracle表的Java程序
    Linux学习_003_虚拟机CentOS 7.5 如何固定IP地址
    Linux学习_002_VMware12.0 Pro 中安装 CentOS-7.5(桌面版)
    Linux学习_001_VMware10.0 && VMware12.0 Pro && VMware14.0 Pro && VMware 15.0 Pro 的安装与破解
    day76_淘淘商城项目_09_商品详情页动态展示实现(jsp+redis) + FreeMarker模板引擎入门 + 商品详情页静态化实现(Win版本的nginx作http服务器)_匠心笔记
    Eclipse注释模板设置详解
  • 原文地址:https://www.cnblogs.com/mrxia/p/3573615.html
Copyright © 2011-2022 走看看