简体   繁体   中英

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

Just like this picture

在此处输入图像描述

write something like below:

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

I test it in chrome and firefox, both seems have this problem, I do not know why

I misunderstood the concept of history.length

The History.length read-only property returns an integer representing the number of elements in the session history, including the currently loaded page.

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

According to the concept , If you click back button then go forward again. the history.length would not change, because history.length is the number of elements in the session history.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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