是否有一个功能,我可以附加作为一个按钮的点击事件,使浏览器回到上一页?
<input name="action" type="submit" value="Cancel"/>
是否有一个功能,我可以附加作为一个按钮的点击事件,使浏览器回到上一页?
<input name="action" type="submit" value="Cancel"/>
当前回答
每次对我都管用
<a href="javascript:history.go(-1)">
<button type="button">
Back
</button>
</a>
其他回答
history.back()
or
history.go(-1)
把这个放到按钮的点击手柄上。它应该是这样的:
<input name="action" onclick="history.back()" type="submit" value="Cancel"/>
每次对我都管用
<a href="javascript:history.go(-1)">
<button type="button">
Back
</button>
</a>
唯一对我有用的是:
function goBackAndRefresh() {
window.history.go(-1);
setTimeout(() => {
location.reload();
}, 0);
}
访问窗口。历史,然后调用回()
window.history.back()
<input name="action" type="submit" value="Cancel" onclick="window.history.back();"/>