代码示例:(标识:jsck_history_length_1)
<!DOCTYPE html>
<html>
<body>

<h1>Window History 对象</h1>

<h2>history.length 属性</h2>

<p>历史列表中的 URL 数量:</p>

<p id="demo"></p>

<p>由于这是新的窗口框架,history.length 将始终返回 1。</p>

<script>
let length = history.length;
document.getElementById("demo").innerHTML = length;
</script>

</body>
</html>
运行结果: