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. ...
随机推荐
- ndk学习13: proc
一.进程相关信息 /proc目录中包含许多以数字命名的子目录,这些数字表示系统当前正在运行进程的进程号,里面包含对应进程相关的多个信息文件 结构如下: 进程相关的信息如下: 部分信息如下 cmdlin ...
- Tomcat启动服务报错:Unknown version string [3.1]. Default version will be used.
用Intellij IDEA 部署Web项目,Tomcat启动后报错Unknown version string [3.1]. Default version will be used. 作者的问题出 ...
- 一个简单的log
#pragma once #include <windows.h> #include <process.h> class CLogger { public: static CR ...
- ubuntu update dns server
edit: /etc/resolvconf/resolv.conf.d/base nameserver 114.114.114.114 execute this: $ resolvconf -u f ...
- VIM基础
http://www.cnblogs.com/wawlian/archive/2012/05/22/2512801.html http://www.cnblogs.com/wawlian/archiv ...
- HttpServletRequest中得到各种信息
1.获得domain: StringBuffer url = request.getRequestURL(); String domain = url.delete(url.length() - re ...
- spring + myBatis 常见错误:注解事务不回滚
最近项目在用springMVC+spring+myBatis框架,在配置事务的时候发现一个事务不能回滚的问题. 刚开始配置如下:springMVC.xml配置内容: spring.xml配置内容 从上 ...
- hdu2457
AC自动机+DP #include <cstdio> #include <queue> #include <cstring> using namespace std ...
- iOS AES加密解密实现方法
使用方法 先导入头文件 #import "NSData+AES.h" //AES测试 //用来密钥 NSString *key = "; //用来发送的原始数据 NSSt ...
- HDU 4865 Peter's Hobby(概率、dp、log)
给出2个影响矩阵,一个是当天天气对湿度的影响,一个是前一天天气对当天天气的影响. 即在晴天(阴天.雨天)发生Dry(Dryish.Damp.Soggy)的概率,以及前一天晴天(阴天.雨天)而今天发生晴 ...