有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. spring ext 跨域

    read方法中调用的response对象是父类BaseController的一个成员变量. spring默认bean的生命周期Score为singleton单例模式. 当多线程并发使用同一bean, ...

  2. Spring Data JPA进阶——Specifications和Querydsl

    Spring Data JPA进阶--Specifications和Querydsl 本篇介绍一下spring Data JPA中能为数据访问程序的开发带来更多便利的特性,我们知道,Spring Da ...

  3. 数据库Error:The ScriptCollection in ScriptName not find

    System.InvalidOperationException: The ScriptCollection in ScriptName not find 在 WMI.SQL.HELPER.CONFI ...

  4. 【leetcode】Merge Intervals

    Merge Intervals Given a collection of intervals, merge all overlapping intervals. For example,Given  ...

  5. poj 1611(并查集)

    http://poj.org/problem?id=1611 题意:有个学生感染病毒了,只要是和这个学生接触过的人都会感染,而和这些被感染者接触的人,也会被感染,现在给定你一些协会的人数,以及所在学生 ...

  6. kali安装vmware tools

    昨天在网上搜了半天如何在kail下安装tools工具,结果都没有成功,今天就来说说我是怎么安装成功的. 1.按照网上的办法只能到这一步,一直提示找不到路径,点了回车也会照常出现这样的情况. Searc ...

  7. ACM/ICPC 之 BFS(离线)+康拓展开(TSH OJ-玩具(Toy))

    祝大家新年快乐,相信在新的一年里一定有我们自己的梦! 这是一个简化的魔板问题,只需输出步骤即可. 玩具(Toy) 描述 ZC神最擅长逻辑推理,一日,他给大家讲述起自己儿时的数字玩具. 该玩具酷似魔方, ...

  8. 请不要用SECONDS_BEHIND_MASTER来衡量MYSQL主备的延迟时间【转】

    本文来自:http://www.woqutech.com/?p=1116 MySQL 本身通过 show slave status 提供了 Seconds_Behind_Master ,用于衡量主备之 ...

  9. linux 共享内存实现

    说起共享内存,一般来说会让人想起下面一些方法:1.多线程.线程之间的内存都是共享的.更确切的说,属于同一进程的线程使用的是同一个地址空间,而不是在不同地址空间之间进行内存共享:2.父子进程间的内存共享 ...

  10. Divide and conquer:K Best(POJ 3111)

     挑选最美的珠宝 题目大意:挑选k个珠宝使得∑a/∑b最大,输出组合数 最大化平均值的标准题型,二分法就好了,一定要注意范围(10e-7),如果是10e-8就会tle,10e-6就是wa #inclu ...