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. Oracle恢复drop误删除的表和建用户操作

    一.表的恢复 对误删的表,只要没有使用PURGE永久删除选项,那么从flash back区恢复回来希望是挺大的.一般步骤有: 1.从flash back里查询被删除的表 select * from r ...

  2. windows调试本地启动的tomcat

    我们一般都通过Eclipse进行tomcat的本地调试,但有些特殊情况下需要直接本地启动tomcat(进入tomcat的bin目录下执行startup.bat),此时我们可以利用类似远程调试模式的方式 ...

  3. 【转】Jmeter在命令行运行技巧

    For non-interactive testing, you may choose to run JMeter without the GUI. To do so, use the followi ...

  4. 网络监控之一:netstat命令

    netstat命令用于显示与IP.TCP.UDP和ICMP协议相关的统计数据,一般用于检验本机各端口的网络连接情况.netstat是在内核中访问网络及相关信息的程序,它能提供TCP连接,TCP和UDP ...

  5. PL/SQL 训练03 --异常

    --程序员在开发的时候,经常天真的认为这个世界是完美的,用户如同自己般聪明,总能按照自己设想的方式--操作系统输入数据.但残酷的事实告诉我们,这是不可能的事情,用户总会跟我们相反的方式操作系统--于是 ...

  6. Cassandra学习五 使用Key的正确姿势

    NoSQL一般是反范式的,比如提倡数据冗余,使得不至于写出非常复杂的SQL语句. Cassandra之中一共包含下面5中Key: Primary Key: 用来获取某一行的数据,可以是一列或多列   ...

  7. MongDB安装使用

    4.MongoDB 下载 MongoDB 提供了可用于 32 位和 64 位系统的预编译二进制包,你可以从MongoDB官网下载安装,MongoDB 预编译二进制包下载地址:https://www.m ...

  8. Java中 单例(Singleton)的两种方式

    第一种(饿汉式单例模式):在声明变量时实例化 public class Singleton { //静态初始化自动实例化 private static Singleton instance = new ...

  9. 在VS13上编译通过的代码放在12上编译-错误:l __dtoui3 referenced in function _event_debug_map_HT_GROW

    在VS13上编译通过的代码放在12上编译 遇到错误:l __dtoui3 referenced in function _event_debug_map_HT_GROW 1>------ 已启动 ...

  10. 16-EasyNetQ之自动订阅者

    EasyNetQ v0.7.1.30版本有了一个简单AutoSubscriber.你能够使用它很容易的去扫描指定程序集中实现了IConsume 或 IConsumeAsync接口的类,然后这个自动订阅 ...