from https://dev.opera.com/articles/efficient-javascript

Occasionally, it is necessary to change the page address using a script. The typical way to do this is by assigning a new address to location.href. This adds a history entry, and loads a new page, in the same way as activating a normal link.

In some cases, this extra history entry is unwanted, as the user will not need to go back to the earlier page. This is particularly useful if working in a situation where memory usage is critical. The memory used by the current page can be recovered by replacing the history entry instead. This is done using thelocation.replace() method.

location.replace('newpage.html');

Note that the page may still remain in cache, and may use memory there, but this will not be quite so much as if it were also kept in history.

location.replace() keeps the history under control的更多相关文章

  1. js 页面刷新location.reload和location.replace的区别小结

    reload 方法,该方法强迫浏览器刷新当前页面. 语法: location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前 ...

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

    有3个html页面(.html, .html, .html). 进系统默认的是1.html ,当我进入2.html的时候, .html里面用window.location.replace(" ...

  3. 【js 方法】js 页面刷新location.reload和location.replace的区别 【转】

    [转]:http://zccst.iteye.com/blog/2162658 reload 方法,该方法强迫浏览器刷新当前页面. 语法: location.reload([bForceGet]) 参 ...

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

    简单说说:有3个jsp页面(1.jsp,  2.jsp,  3.jsp). 进系统默认的是1.jsp ,当我进入2.jsp的时候, 2.jsp里面用window.location.replace(&q ...

  5. Coursera SDN M1.1 SDN History: Central Control

    source Structure 1.讨论SDN的时间线,从1980s至今. 2.认识到SDN背后的原则和idea. 3.识别SDN起源的架构主题. NOTE Four Chapter in SDN ...

  6. location.assign 与 location.replace的区别

    window.location.assign(url) : 加载 URL 指定的新的 HTML 文档. 就相当于一个链接,跳转到指定的url,当前页面会转为新页面内容,可以点击后退返回上一个页面. w ...

  7. location.reload() 和 location.replace()的区别和应用

    首先介绍两个方法的语法: reload 方法,该方法强迫浏览器刷新当前页面.语法: location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 fals ...

  8. Android webview “location.replace” 不起作用

    js解决方法: function locationReplace(url){ if(history.replaceState){ history.replaceState(null, document ...

  9. location.replace()和location.href=进行跳转的区别

    location.href 通常被用来跳转到指定页面地址;location.replace 方法则可以实现用新的文档替换当前文档;location.replace 方法不会在 history 对象中生 ...

随机推荐

  1. 9 闭包——《Swift3.0从入门到出家》

    8  闭包 Swift语言中可以使用一块独立代码块替代函数的定义,称独立的代码块为闭包 闭包格式为: {(参数列表)->返回值类型    in 执行语句 } 例子: <1>使用闭包实 ...

  2. phpcms文档

    http://www.phpcms.cn/doc/PHPCMSDocumentor/cache_module.html http://www.cnblogs.com/Braveliu/p/507493 ...

  3. Rest之路 - 第一个Rest程序

    在 Eclipse 里新建一个 Dynamic project 将 Jersey 的 jar 包,拷贝到 WebContent -> WEB-INF -> lib 文件夹 Add jars ...

  4. Web验证码图片的生成-基于Java的实现

    验证码图片是由程序动态产生的,每次访问的内容都是随机的.那么如何采用程序动态产生图片,并能够显示在客户端页面中呢?原理很简单,对于java而言,我们首先开发一个Servlet,这个Servlet的任务 ...

  5. java多态介绍温故而知新

    多态是同一个行为具有多个不同表现形式或形态的能力. 多态就是同一个接口,使用不同的实例而执行不同操作. 多态性是对象多种表现形式的体现. 现实中,比如我们按下 F1 键这个动作: 如果当前在 Flas ...

  6. socket通讯实例与TCP/UDP的区别

    一.socket代码实例 1.简单的socket通讯: 服务端代码实例: import socket sock = socket.socket(socket.AF_INET, socket.SOCK_ ...

  7. 如何发布可用于azure的镜像文件

    摘要:本篇文章讲述如何将蝉知,禅道和然之发布azure的镜像. azure是微软提供的云服务平台.并且针对中国用户专门开通了www.windowsazure.cn站点.同时还成了微软开放中国公司,推出 ...

  8. 用Dos黑窗口运行Cmd命令

    public class BlackWindow { private static BlackWindow _instance; public static BlackWindow Instance ...

  9. Aggregate可以做字符串累加、数值累加、最大最小值

    Aggregate("", (m, n) => m + n + ".").TrimEnd('.'); .Aggregate(0, (m, n) => ...

  10. Swagger SpringBoot 集成

    说明:Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参数和模型紧密集 ...