JS Redirect Prevents Going Back to Previous Page, No History Record
发布于 2026-07-06 10:45:47
2 次浏览
window.location.replace
1
|
window.location.replace('page to redirect to')
|
1 2 3 4
|
let backLen = history.length history.forward() history.go(-backLen) window.location.replace('/#/home')
|
window.location.hash
JS clears history by changing location.hash
Use the following method to assign a value to hash
1
|
window.location.hash = 'hash value'
|
This will add a new history entry in window.history. If you want to clear this record (otherwise clicking back will return to the previous hash page), you can use:
1
|
window.location.replace(window.location.href.toString().replace(window.location.hash, '') + "#
|
暂无评论。