当前位置:网站首页>history.go()和history.back(),history.go()不刷新
history.go()和history.back(),history.go()不刷新
2022-07-21 21:36:00 【旺仔好吃糖】
history.go()和history.back(),history.go()不刷新
history.back()
back():加载history列表中前一个url,原页面表单内容保存,即后退
history.go()
go():加载history列表中的某个具体页面,即后退或前进+刷新
区别:
history.go(value)会前往任何一个页面;但是history.back()不管括号内传入什么参数,都只会返回上一次刷新的页面,而不能进行多次跳转
history.go(-1)不刷新
//html
<img src="./picture/left.png" alt="" onclick='sessionStorage.setItem("refresh", "true");history.go(-1);'>
//js
//强制刷新页面
window.addEventListener('pageshow', function(event) {
if(event.persisted) {
location.reload();
} else {
if(sessionStorage.getItem('refresh') === 'true') {
location.reload();
}
}
sessionStorage.removeItem('refresh');
});
补充:
pageshow事件(给window添加):这个事件在页面显示时触发,无论页面是否来自缓存。在重新加载的页面中,pageshow会在load事件触发后触发;
persisted:是pageshow事件的event对象包含的布尔值属性
对于pageshow事件,如果页面是从bfcache(往返内存)中加载的,则这个属性的值为true;否则,这个属性的值为false。
边栏推荐
- Ansible项目最佳实践
- [quick start tutorial 5] crazy shell · open source formation UAV - flight control firmware burning
- [development tutorial 5] open source Bluetooth heart rate waterproof sports Bracelet - battery power detection
- 《架构设计2.0大型分布式系统架构方法论与实践》三高笔记
- 实操演练 | 使用 Navicat 对 MySQL 表进行分区
- FPGA——SPI总线控制flash(1)(含代码)
- 长安全新最强SUV来袭,内饰很立体,科技感爆棚
- Ten suggestions on how to do research efficiently for graduate students
- 知识点复习(持续更新版)
- [exercise C] how many steps does it take to find a number at least? It can be changed into Fibonacci number
猜你喜欢
Day010 cycle structure
HCIP第十二天
[travel notes] gifts from seniors 2-july 21, 2022
For() loop and quadratic for nesting of loop structure
How to choose the primary key UUID, self incrementing ID and snowflake algorithm of MySQL? (glory Collection Edition)
Jmeter进阶之性能测试响应结果保存到本地
Actual combat of flutter - customized keyboard (III)
Advantages of vr virtual simulation teaching software for cable fault monitoring
关于目前流行的 Redis 可视化管理工具的详细评测
[stl]vector Simulation Implementation
随机推荐
JVM parameter configuration description
缺陷報告作業
Real time joint simulation of smart grid hardware based on FPGA Jetson
Sentinel vs Hystrix 限流对比,该如何选择?
C language explanation series -- Explanation of goto sentences and simple exercises of circular sentences
Ten suggestions on how to do research efficiently for graduate students
uniapp封装请求
[mathematics of machine learning 01] countable sets and uncountable sets
一个仅需三步配置就能生成免费个人博客的开源模板:vdoing-template
Actual combat of flutter - customized keyboard (II)
Force deduction record: Sword finger offer (1) - jz3-12
[MySQL] 20-how MySQL creates and manages super detailed summaries of tables
Elephant Swap的LaaS方案优势分析,致eToken表现强势
As a test, how to effectively communicate with unreasonable developers
Robust optimization of space-based relay in Internet of things based on UAV
Flutter实战-自定义键盘(三)
Global Groundwater Simulation and monitoring: opportunities and challenges
From the 5K monthly salary of Tencent outsourcing to the 15K monthly salary of transferred regular employees, who can understand the 168 days of sadness
How does MySQL data 900w+ achieve from 17s to 300ms? Charm of SQL optimization (glory Collection Edition)
Virtual machine kernel parameters permanently effective configuration