我们开发中有一个需求,不管打开多少页面,如果页面出现了错误,就要返回第一页。
然后偶然间发现window.history属性含有length属性。
historyLength =window.history.length;
window.history.go(-(historyLength -1));这样就成功了。
我们开发中有一个需求,不管打开多少页面,如果页面出现了错误,就要返回第一页。
然后偶然间发现window.history属性含有length属性。
historyLength =window.history.length;
window.history.go(-(historyLength -1));这样就成功了。
本文标题:JS返回浏览器历史第一页
本文链接:https://www.haomeiwen.com/subject/haoeyqtx.html
网友评论