繁体   English   中英

在 history.back() 之后, hisytory.pushState 不会增加历史长度

[英]After history.back() , hisytory.pushState does not increment history length

就像这张照片一样

在此处输入图像描述

写如下内容:

history.pushState(null,null,"./abc");
history.back();
console.log(history.length);
history.pushState(null,null,"./abc");
console.log(history.length);

我用chrome和firefox测试了一下,好像都有这个问题,不知道为什么

我误解了history.length的概念

History.length 只读属性返回一个整数,表示会话历史记录中的元素数量,包括当前加载的页面。

https://developer.mozilla.org/en-US/docs/Web/API/History/length

根据概念,如果单击back按钮,则再次前进。 history.length 不会改变,因为 history.length 是会话历史中元素的数量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM