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. ...
随机推荐
- p5349 幂
分析 https://www.cnblogs.com/cjyyb/p/10822490.html 代码 #include<bits/stdc++.h> using namespace st ...
- JS new date在IOS出现的问题
实例代码: input = input.replace(/\-/g, "/");//横杠的时间不能被识别,所以要替换程斜杠 let time = new Date(input); ...
- delphi 遍历窗口
http://blog.163.com/t_form/blog/static/12348523220115132155814/ function EnumWindowsProc_2(hwnd: HWN ...
- SoapUI学习之SOAP和REST的区别
一.Soap和Rest的定义 SOAP(Simple Object Access Protocol 简单对象访问协议),用于在Web Service中把远程调用和返回封装成机器可读的格式化数据,事实上 ...
- ABI与API的区别
ABI是定义二进制级别的,两个模块的接口 比如一个二进制模块想要调用另外一个二进制模块提供的功能,它需要知道怎样通过汇编语言(即机器指令)去调用,以及怎样传递相应的参数和返回值(通过寄存器还是栈内存, ...
- Matlab入门基础
matlab入门篇,一些基础用法记一下~ M语言是解释型语言 who:查看当前变量 whoes:查看当前变量及其维数.所占字节数等. clear: 清除所有变量 clear + 变量名 ...
- static定义属性
static关键字在Java程序开发过程中主要进行属性和方法的定义. static 定义属性: 类中的最主要的组成就是属性和方法,那么在说static之前,先看看一下问题: 范例:定义一个描述球的信息 ...
- [19/05/19-星期日] CSS_css的声明和选择器
一.引言 HTML的作用是负责数据的格式展示,如果使用它来搞数据的样式,则发现样式书写出来太麻烦,不易于维护: HTML可以有效组织数据的展示,但是不同类型数据在浏览器中的分布没有办法展示. HTML ...
- Java之九九乘法表
public class MultiplicationTable { public static void main(String[] args) { for(int i=1;i<=9;i++) ...
- Oracle数据库的特点与工作原理
Oracle数据库的特点 1.开放性: Oracle能在所有主流平台上运行(包括Windows),完全支持所有的工业标准,采用完全开放策略,可以使客户选择最适合的解决方案,对开发商全力支持. 2.可伸 ...