admin管理员组文章数量:1303414
Here is 1.html
<!DOCTYPE html>
<html>
1
<script>
let time = 0;
setInterval(() => {
if (time === 500) location.href = '/2.html';
time++;
}, 1);
</script>
</html>
And here is 2.html
<!DOCTYPE html>
<html>
<body>
2
</body>
</html>
If access to 1.html
, according to setInterval()
, the page will be moved to 2.html
0.5 seconds later by location.href
new value.
However, it is not possible to go back to 1.html
using back button on a browser.
I've heard that the reason of it is location.href
was executed not by user events (like clicking) but by force caused by my code.
I want to know how to make it work!
I tried history.pushState
method to make the browser know that there is one more page you(browser) should add to the stack.
It worked if I go back to previous page by history.back()
.
However, it still didn't work if I tried to go back to previous page by pressing go back button on a browser.
本文标签:
版权声明:本文标题:javascript - Is it possible to use the back button to go back to the previous page from a page that was moved by location.href w 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741700540a2393261.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论