标签:win length ack pop 页面 替换 state cat OLE
window.onpopstate = console.log
window.onhashchange = console.log
1. history.pushState({a:1,b:2}, ‘title‘, ‘/test‘) // /test
2. history.pushState({test:2,b:33}, ‘title2‘, ‘/test2‘) // /test2
3. history.back() // /test log: {state:{a:1,b:2},...other}
4. history.forward() // /test2 log: {state:{test:2,b:33}, ...other}
5. history.back()
6. history.pushState({test: 3, b:44}, ‘title3‘, ‘/test3‘) // history.length === 2 /test2被删除
7. location.hash = ‘#test3‘ // 会立刻触发onpopstate与hashchange 并且增加history记录。
8. history.pushState(null,‘‘,‘#a‘) // 不会触发history与hashchange
9. history.back() // 触发history与hashchange
标签:win length ack pop 页面 替换 state cat OLE
原文地址:https://www.cnblogs.com/gsgs/p/12989831.html