Document.location.href和.replace的区别
转自: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的区别的更多相关文章
- window.location.href和document.location.href、document.URL的区别
1.document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个documen ...
- window.location.href 和 document.location.href
document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个document. ...
- windows.open window.location.href的用法和区别
window.location.href 只能在当前页面打开,不能用新窗口打开 windows.open("URL","窗口名称","窗口外观设定& ...
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的用法与区别(跳出iframe方法)
"window.location.href"."location.href"是本页面跳转 "parent.location.href"是上一 ...
- 解决document.location.href下载文件时中文乱码
1:tomcat 安装路径下 找到 conf文件下的server.xml 2:<Connector port="8080" URIEncoding="utf-8&q ...
- window.location.href/replace/reload()--页面跳转+替换+刷新
一.最外层top跳转页面,适合用于iframe框架集 top.window.location.href("${pageContext.request.contextPath}/Login_g ...
- 5. window.location.href/replace/reload()--页面跳转+替换+刷新
1.window.location=url; window.location 对象用于获得当前页面的地址 (URL),并把浏览器重定向到新的页面. 一.最外层top跳转页面,适合用于iframe框架集 ...
- js中的 window.location、document.location、document.URL 对像的区别(转载)
原文:http://www.cr173.com/html/18417_1.html 当我们需要对html网页进行转向的时候或是读取当前网页的时候可以用到下面三个对像: window.location. ...
- document.URL vs window.location.href All In One
document.URL vs window.location.href All In One document.URL 与 window.location.href 两者有啥区别 document. ...
随机推荐
- mysql-debug: Thread stack overrun
bug info 报错信息: java.sql.SQLException: Thread stack overrun: 5456 bytes used of a 131072 byte stack, ...
- axios 讲解 和vue搭建使用
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Activity传递参数——传递简单数据
一.新建一个空的工程 二.在主界面中添加一个按钮 三.新建一个空的activity,并命名为TheAty 四.修改MainActivity.java中的onCreate函数 protected voi ...
- IE6&IE7 bug
IE6 Bugs 1 .不支持用样式设置 <abbr> 元素 2 .不支持以连字符和下划线开头的 class 和 ID 名 3 . <select> 元素总是出现在堆叠最上面, ...
- 版本工具管理之----git
如何查看隐藏文件夹: 如果你看不到.git目录,你需要让隐藏的文件可见.具体做法就是打开一个Terminal窗口,输入以下命令: defaults write com.apple.finder App ...
- New Concept English three (40)
23w/m 48 errors It has never been explained why university students seem to enjoy practical jokes mo ...
- jquery 中多条件选择器,相对选择器,层次选择器的区别
一.Jquery常用的过滤选择器如下所示: 1.:first,选取第一个元素,比如$("div:first")选取第一个div元素 2.:last,选取最后一个元素,比如$(&qu ...
- Android的方法和属性(1)
1.Activity常用的方法 View findViewById(int id) //根据组件的ID取得组件对象 setContentView(int layoutResID) //设置布局文件,设 ...
- poscms仿站知识点总结(一)
最近在做基于poscms系统的企业站仿站项目,这个系列用于总结项目中遇到的一些前端问题,至于poscms,待我摸透之后再总结... 进入正题吧,仿站,首先是用仿站小工具把要仿的模板站扒下来,有时候会出 ...
- ActionContextCleanUp作用
延长action中属性的生命周期,包括自定义属性,以便在jsp页面中进行访问,让actionContextcleanup过滤器来清除属性,不让action自己清除. 为了使用WebWork,我们只需要 ...