JS返回浏览器历史第一页

2019-02-22  本文已影响0人  aloe_v

我们开发中有一个需求,不管打开多少页面,如果页面出现了错误,就要返回第一页。

然后偶然间发现window.history属性含有length属性。

historyLength =window.history.length;

window.history.go(-(historyLength -1));这样就成功了。

上一篇 下一篇

猜你喜欢

热点阅读