window.location.href和window.location.replace的区别
有3个html页面(.html, .html, .html)。 进系统默认的是1.html ,当我进入2.html的时候,
.html里面用window.location.replace("3.html");与用window.location.href("3.html");
从用户界面来看是没有什么区别的,
但是当3.html页面有一个“返回”按钮,调用window.history.go(-);wondow.history.back();
方法的时候,一点这个返回按钮就要返回2.html页面的话,区别就出来了,
当用window.location.replace("3.html");连到3.html页面的话,
.html页面中的调用window.history.go(-);wondow.history.back();方法是不好用的,会返回到1.html
。
当用window.location.href("3.html");连到3.html页面的话,
.html页面中的调用window.history.go(-);wondow.history.back();方法是好用的,会返回2.html。
因为window.location.replace("3.html");是不向服务器发送请求的跳转,
而window.history.go(-);wondow.history.back();方法是根据服务器记录的请求决定该跳到哪个页面的,
所以会跳到系统默认页面1.html 。window.location.href("3.html");是向服务器发送请求的跳转,window.history.go(-);wondow.history.back();方法是根据服务器记录的请求决定该跳到哪个页面的,
所以就可以返回到2.html。
window.location.href和window.location.replace的区别的更多相关文章
- 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 ...
- 关于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和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 和 document.location.href
document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个document. ...
随机推荐
- BZOJ 1041
题目描述 给出\(n\),求\(x^2+y^2=n^2,x,y,z\in \mathbb{Z}\)的解数. 复杂度 \(O\left(T_{\mathtt{factorization}}(n)\rig ...
- 【云计算】docker相关开源项目、工具
十大基于Docker的开发工具 作者 郭蕾 发布于 2014年8月19日 | 注意:QCon全球软件开发 ...
- XsltListViewWebPart 和自定义列表视图
http://msdn.microsoft.com/zh-cn/library/ff806162(v=office.14).aspx
- Light OJ 1032
数位dp,许多数位dp需要统计某种模式(子串)出现的数量,这种题通常需要在递归参数中加入高位已经出现过的模式的数量. #include <cstdio> #include <cstr ...
- Ubuntu 新建swap分区及启用
个人电脑配置:500G机械硬盘+16G NGFF SSD+8G Physical Memory 之前安装Ubuntu16.04,默认装到NGFF的SSD里,/和swap分区一共才16G,于是删除swa ...
- Python:IDLE清屏
清屏很简单,为IDLE增加一个清屏的扩展ClearWindow即可. 首先下载clearwindow.py(点击可直接下载,不能下载的可以右键保存,格式为py结尾), 将这个文件放到Python安装目 ...
- diff & pattch 命令
基础知识 该命令的功能为逐行比较两个文本文件,列出其不同之处.它比comm命令完成更复杂的检查.它对给出的文件进行系统的检查,并显示出两个文件中所有不同的行,不要求事先对文件进行排序. 语法:diff ...
- tomcat bin 中startup.sh中的环境变量配置
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 JRE_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64/jre P ...
- 【linux】配置SSH免密码登陆
1.输入ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa 其中''里的是登陆的密码,因为要设置免密码,所以''里是什么都没有的,空格也不行 2.输入 cat ~/.ss ...
- web前端打印总结
资料: http://blog.5ibc.net/p/39927.html 正文: 简单的说就是映入两个css文件 <link/> <link/> 每个css文件都有一个属性是 ...