有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的区别的更多相关文章

  1. window.location.href 和 window.location.replace 的区别

    window.location.href  和  window.location.replace 的区别 1.window.location.href=“url”:改变url地址: 2.window. ...

  2. window.location.href 与 window.loaction.replace区别

    window.location.href和window.location.replace的区别 1.window.location.href=“url”:改变url地址: 2.window.locat ...

  3. 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法

    location.href 和 window.location.href 区别: 1.location.href 可以直接跳转其他地址(不属于本项目) 也可以跳转本项目中的 2.window.loca ...

  4. window.location.href和window.open的几种用法和区别

    使用js的同学一定知道js的location.href的作用是什么,但是在js中关于location.href的用法究竟有哪几种,究竟有哪些区别,估计很多人都不知道了. 一.location.href ...

  5. window.location.href和document.location.href、document.URL的区别

    1.document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个documen ...

  6. window.location.href.substr(window.location.href.length - 6)

    if (window.location.href.substr(window.location.href.length - 6) == "flag=1") { var tOptio ...

  7. window.location和window.location.href和document.location的关系

    1,首先来区分window.location和window.location.href. window.location.href是一个字符串. 而window.location是一个对象,包含属性有 ...

  8. window.top.location.href 和 window.location.href 的区别

    "window.location.href"."location.href"是本页面跳转. "parent.location.href" 是 ...

  9. window.location.href 和 document.location.href

    document表示的是一个文档对象,window表示的是一个窗口对象,一个窗口下可以有多个文档对象. 所以一个窗口下只有一个window.location.href,但是可能有多个document. ...

随机推荐

  1. STS新建的maven项目报错问题

    STS新建的maven项目报错问题 解决方法:打开pom.xml文件添加 <dependency> <groupId>javax.servlet</groupId> ...

  2. Function接口 – Java8中java.util.function包下的函数式接口

    Introduction to Functional Interfaces – A concept recreated in Java 8 Any java developer around the ...

  3. fork详解

    [本文链接] http://www.cnblogs.com/hellogiser/p/fork.html [代码] 下面的代码输出多少个-?  C++ Code  123456789101112131 ...

  4. 几种Linux 查询外网出口IP的方法

    Curl 纯文本格式输出: curl icanhazip.com curl ifconfig.me curl curlmyip.com curl ip.appspot.com curl ipinfo. ...

  5. hiho一下第二周 Trie树

    题目链接:http://hihocoder.com/problemset/problem/1014 #include <iostream> #include <cstdio> ...

  6. Spring+SpringMVC+Mybatis 多数据源整合(转)

    转载自:http://blog.csdn.net/q908555281/article/details/50316137 目录(?)[-]拷贝所需jar拷贝jar文件需要的jar文件入下图所示因为我的 ...

  7. 20145213《Java程序设计》第一周学习总结

    20145213<Java程序设计>第一周学习总结 教材学习内容总结 期待了一个寒假,终于见识到了神秘的娄老师和他的Java课.虽说算不上金风玉露一相逢,没有胜却人间无数也是情理之中,但娄 ...

  8. java获取客服端信息(系统,浏览器等)

    String agent = request.getHeader("user-agent"); System.out.println(agent); StringTokenizer ...

  9. IOS - AFN

    #import "ViewController.h"#import "AFNetworking.h"#import "SSZipArchive.h&q ...

  10. asp.net 曲线图

    public void draw(DataTable dt) { //取得记录数量 int count = dt.Rows.Count; //记算图表宽度 int wd = 80 + 20 * (co ...