【发布时间】:2020-09-12 07:17:13
【问题描述】:
我做了一些研究,但找不到解决方案。
我有一个landingpage.html。当用户按下浏览器中的后退按钮时,我想将用户重定向到 anotherpage.html。
所以我试过这段代码:
let currentUrl = location.href;
history.replaceState('', '', 'anotherpage.html');
history.pushState('', '', currentUrl);
它的工作方式并不像预期的那样:当按下后退按钮时,浏览器地址栏会显示 anotherpage.html 页面,但不会发生实际的重定向。
【问题讨论】:
标签: javascript redirect back-button