【发布时间】:2016-12-09 15:35:09
【问题描述】:
我有一个在线测试,它连续运行超过 5 个网页而没有暂停。我希望后退按钮(如果使用)重定向到测试页面之前的页面,防止它被用来循环遍历测试页面。我认为历史 API 可能是要走的路,并尝试将它与这个脚本一起使用:
var stateObj = { url: "/index.php/toeic_introduction"};
// Updates the current history entry timerArray[i][2].
window.history.replaceState(stateObj, "","/index.php/toeic_introduction");
// Creates a new history entry.
window.history.pushState(stateObj, "","/index.php/toeic_introduction");
这适用于网址显示在地址行中但后退按钮未按要求重定向的情况。我什至不确定是否可以通过这种方式实现对后退按钮的控制。我曾想过禁用后退按钮并在网上四处查看,但这个选项似乎相当有问题。我当然欢迎任何 cmets 或建议。
【问题讨论】: