簡體   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