Js中window.location.href和window.location.replace的区别
href相当于打开一个新页面,
replace相当于替换当前页面;
这里打开页面都是针对历史记录来说,在页面上看完全相同,只是浏览器的history表现不同如果在1.html中点击链接到2.html,
然后2.html中使用href跳转到3.html,这时(页面是3.html)按浏览器后退按钮将返回2.html,
但如果上面在2.html中调用replace进入3.html,
再点击后退按钮的时候,
会退回到1.html(相当于replace方法将2.html的历史访问记录替换为3.html,所以访问轨迹就成了1.html→3.html)作者:一只懒惰的蜜蜂
链接:https://www.jianshu.com/p/a85ea96f2e6b
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Js中window.location.href和window.location.replace的区别的更多相关文章
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
location.href 和 window.location.href 区别: 1.location.href 可以直接跳转其他地址(不属于本项目) 也可以跳转本项目中的 2.window.loca ...
- window.location.href和window.open的几种用法和区别
使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...
- window.location.href 和 window.location.replace 的区别
window.location.href 和 window.location.replace 的区别 1.window.location.href=“url”:改变url地址: 2.window. ...
- window.location.href 与 window.loaction.replace区别
window.location.href和window.location.replace的区别 1.window.location.href=“url”:改变url地址: 2.window.locat ...
- window.location.href和document.location.href、document.URL的区别
1.document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个documen ...
- window.location.href.substr(window.location.href.length - 6)
if (window.location.href.substr(window.location.href.length - 6) == "flag=1") { var tOptio ...
- window.location和window.location.href和document.location的关系
1,首先来区分window.location和window.location.href. window.location.href是一个字符串. 而window.location是一个对象,包含属性有 ...
- window.top.location.href 和 window.location.href 的区别
"window.location.href"."location.href"是本页面跳转. "parent.location.href" 是 ...
- window.location.href和window.location.replace的区别
有3个html页面(.html, .html, .html). 进系统默认的是1.html ,当我进入2.html的时候, .html里面用window.location.replace(" ...
- window.location.href和window.top.location.href的区别
if (window.location.href == window.top.location.href) { window.top.location.href = "/index. ...
随机推荐
- leetcode-mid-array-334 Increasing Triplet Subsequence-NO
mycode time limited class Solution(object): def increasingTriplet(self, nums): """ ...
- oracle常用sql语句和函数
--查询表的字段数 select count(*) from user_tab_columns where table_name = '表名'; --查询数据库用户密码的profile(一般为defa ...
- java操作JSON字符串转换成对象的时候如何可以不建立实体类也能获取数据
引入依赖 <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson& ...
- leetcode 884. 两句话中的不常见单词 (python)
给定两个句子 A 和 B . (句子是一串由空格分隔的单词.每个单词仅由小写字母组成.) 如果一个单词在其中一个句子中只出现一次,在另一个句子中却没有出现,那么这个单词就是不常见的. 返回所有不常用单 ...
- 深入理解webpack(二) webpack-dev-server基本配置
摘要:webpack-dev-server是一个使用了express的Http服务器,它的作用主要是为了监听资源文件的改变,该http服务器和client使用了websocket通信协议,只要资源文 ...
- C 语言跟 C++ 的差异比较
C++ 完整的 CHM 版离线手册,可以 从这里下载. C++头文件不必是 .h 结尾 C语言中的标准库头文件,例如 math.h 和 stdio.h,在C++中被命名为 cmath 和 cstdio ...
- Java ——if条件语句 switch语句
本节重点思维导图 if条件语句 //如果条件表达式成立,执行语句块 if(条件表达式){ //…语句块 } 如果语句块只有一条语句,大括号可以省略,否则不能省略. 建议,不管有几条语句,都不要省略大 ...
- python基础-7.2文件内置属性__doc__ __file__ __package__ __cached__ __name__
__doc__ #py文件开头的注释文字 __file__ #当前py文件的路径 __package__ #包含文件所在包,用 . 分隔,当前文件为None,导入的其他文件:指定文件所在包,用.分隔. ...
- Eclipse解除已关联的Coding远程仓库,重新关联github上的远程仓库
1.在Eclipse中的Git Repositories中找到要解除的仓库,依次找到Remote--origin[视自己的实际情况选择], 2.选中origin,右键选择Delete Remote , ...
- SCUT - 106 - 花式ac - 主席树/启发式合并Treap
https://scut.online/p/106 错在这组样例,发现是离散化之后,对k访问的时候也是应该访问离散化之后的k. 12 4 1 1 2 2 5 5 4 4 3 3 2 1 1 3 3 5 ...