JS history.length属性

history.length属性

JavaScript中window对象的history.length属性,可以用于获取当前浏览器窗口历史列表中的URL的数量,该属性的返回值至少为1,即浏览器窗口的历史列表中至少包括当前的页面。


语法

window.history.length

提示:window可以省略。


history.length实例代码,及在线编辑器

<button onclick="url_length()">按钮</button>

<script>
  function url_length(){
    alert(history.length)
  }
</script>

全栈前端 / JavaScript语法 :





















Copyright © 2022-2024 笨鸟工具 x1y1z1.com All Rights Reserved.