转自:https://www.cnblogs.com/GT_Andy/archive/2007/10/31/1922138.html
1 Document.location.href和.replace的区别
document.location.href和document.location.replace都可以实现从A页面切换到B页面,但他们的区别是: 用document.location.href切换后,可以退回到原页面。 而用document.location.replace切换后,不可以通过“后退”退回到原页面。 关于document.location.href或其他可回退的切换方式,我还发现一个细节, 用个例子来说明: 假设有A.htm B.htm C.htm三个页面 A.htm里有这样一句:document.location.href="/b.htm"; b.htm里有这样一句:document.location.href="/c.htm"; 注意两个都是可回退的切换。 1:当从A切换到B再切换到C时,实际内存中保留了三个页面:A、B、C 2:回退到B时,C页面被清出内存! 3:再次回退,到A页面时,B页面也被清出内存! 4:再次向前(不是用切换而是用向前)转到B页面时, 内存中保留的是A和B >>>当一个文档被location.replace()替换后,它就会从当前的历史对象中移除了

Document.location.href和.replace的区别的更多相关文章

  1. window.location.href和document.location.href、document.URL的区别

    1.document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个documen ...

  2. window.location.href 和 document.location.href

    document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个document. ...

  3. windows.open window.location.href的用法和区别

    window.location.href  只能在当前页面打开,不能用新窗口打开 windows.open("URL","窗口名称","窗口外观设定& ...

  4. 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法与区别(跳出iframe方法)

    "window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...

  5. 解决document.location.href下载文件时中文乱码

    1:tomcat 安装路径下 找到 conf文件下的server.xml 2:<Connector port="8080" URIEncoding="utf-8&q ...

  6. window.location.href/replace/reload()--页面跳转+替换+刷新

    一.最外层top跳转页面,适合用于iframe框架集 top.window.location.href("${pageContext.request.contextPath}/Login_g ...

  7. 5. window.location.href/replace/reload()--页面跳转+替换+刷新

    1.window.location=url; window.location 对象用于获得当前页面的地址 (URL),并把浏览器重定向到新的页面. 一.最外层top跳转页面,适合用于iframe框架集 ...

  8. js中的 window.location、document.location、document.URL 对像的区别(转载)

    原文:http://www.cr173.com/html/18417_1.html 当我们需要对html网页进行转向的时候或是读取当前网页的时候可以用到下面三个对像: window.location. ...

  9. document.URL vs window.location.href All In One

    document.URL vs window.location.href All In One document.URL 与 window.location.href 两者有啥区别 document. ...

随机推荐

  1. Easyui 行编辑

    之前没用过,突然用了的时候手忙脚乱的感觉  找了官方文档也好 百度了一大堆东西   表示个人脑袋跟不上思路 直接铺上简化的  以后自己 找起来也方便  以下代码已经执行 应该不会再错了 <tab ...

  2. UIView常用属性与方法/UIKit继承结构

    UIView常用属性与方法 @interface UIView : UIResponder<NSCoding, UIAppearance, UIAppearanceContainer, UIDy ...

  3. Python基础学习(第1天)

    写这篇随笔,是看Vamei大大写的Python快速教程的学习笔记,以此自勉,链接:http://www.cnblogs.com/vamei/archive/2012/09/13/2682778.htm ...

  4. 原创:Angular + controllerAs + CoffeeScript的一个问题,及其解决方案

    config是一个待注入的value,它的值是{count:  1} 看代码(用普通函数的写法): $routeProvider.when '/test', template: "Hello ...

  5. New Concept English three (45)

    31w/m 65error In democratic countries any efforts to restrict the freedom of the press are rightly c ...

  6. Redis补充

    Redis补充 (1)redis基本概念 redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set ...

  7. EasyDarwin开源流媒体服务器中一种实现对作用域内new对象自动释放的方法(值得借鉴)

    我们经常在开发过程中,在局部new了一个对象,我们就会在复杂的逻辑过程中担心这个对象是否已经被释放,需要在一大堆的if.else.while.break进行判断new对象是否还存在,或者相同的dele ...

  8. Http基础(记忆笔记)

    地址解析:http://localhost.com:8080/index.htm 协议名:Http 主机名:localhost.com 端口:8080 对象路径:/index.htm 通过域名解析lo ...

  9. ehchache和redis

    Ehcache 在java项目广泛的使用.它是一个开源的.设计于提高在数据从RDBMS中取出来的高花费.高延迟采取的一种缓存方案.正因为Ehcache具有健壮性(基于java开发).被认证(具有apa ...

  10. kali视频(26-30)学习

    第七周 kali视频(26-30)学习 26.KaliSecurity漏洞利用之检索与利用 27.KaliSecurity漏洞利用之Metasploit基础 28.KaliSecurity漏洞利用之M ...